Skip to content

ICE in resolve, at rust/backend/rust-compile-resolve-path.cc fn name, type, var name overlap? #3933

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use
pub fn _v() {
    const FOO: _v = 2;
    let _v = [0; FOO * 3 * 2 / 2];
}

original:

// run-pass
// Check that constant expressions can be used in vec repeat syntax.

// pretty-expanded FIXME #23616

pub fn _v() {

    const FOO: _v = 2;
    let _v = [0; FOO*3*2/2];

}

Version information:

5c3e2ad

Possibly related line of code:

ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment,
const Analysis::NodeMapping &mappings,
location_t expr_locus, bool is_qualified_path)
{
TyTy::BaseType *lookup = nullptr;
bool ok = ctx->get_tyctx ()->lookup_type (mappings.get_hirid (), &lookup);
rust_assert (ok);
// need to look up the reference for this identifier
// this can fail because it might be a Constructor for something
// in that case the caller should attempt ResolvePathType::Compile
auto &nr_ctx

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use

Program output

/tmp/icemaker_global_tempdir.Z4gPrG7syquN/rustc_testrunner_tmpdir_reporting.anw1Na7AcOJb/mvce.rs:2:5: error: mismatched types, expected ‘fn () -> ()’ but got ‘<integer>’ [E0308]
    2 |     const FOO: _v = 2;
      |     ^~~~~      ~~   ~
/tmp/icemaker_global_tempdir.Z4gPrG7syquN/rustc_testrunner_tmpdir_reporting.anw1Na7AcOJb/mvce.rs:3:18: error: cannot apply operator ‘*’ to types <tyty::error> and <integer>
    3 |     let _v = [0; FOO * 3 * 2 / 2];
      |                  ^~~
/tmp/icemaker_global_tempdir.Z4gPrG7syquN/rustc_testrunner_tmpdir_reporting.anw1Na7AcOJb/mvce.rs:3:18: error: cannot apply operator ‘*’ to types <tyty::error> and <integer>
/tmp/icemaker_global_tempdir.Z4gPrG7syquN/rustc_testrunner_tmpdir_reporting.anw1Na7AcOJb/mvce.rs:3:18: error: cannot apply operator ‘/’ to types <tyty::error> and <integer>
/tmp/icemaker_global_tempdir.Z4gPrG7syquN/rustc_testrunner_tmpdir_reporting.anw1Na7AcOJb/mvce.rs:3:14: error: mismatched types, expected ‘usize’ but got ‘<tyty::error>’ [E0308]
    3 |     let _v = [0; FOO * 3 * 2 / 2];
      |              ^   ~~~
crab1: internal compiler error: in resolve, at rust/backend/rust-compile-resolve-path.cc:217
0x2fec938 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:517
0xc0dfbb fancy_abort(char const*, int, char const*)
	../../gcc/diagnostic.cc:1803
0x8fd065 Rust::Compile::ResolvePathRef::resolve(Rust::HIR::PathIdentSegment const&, Rust::Analysis::NodeMapping const&, unsigned long, bool)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:217
0xdcf5eb tree_node* Rust::Compile::ResolvePathRef::resolve_path_like<Rust::HIR::PathInExpression>(Rust::HIR::PathInExpression&)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:68
0xdcf5eb Rust::Compile::ResolvePathRef::Compile(Rust::HIR::PathInExpression&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-resolve-path.cc:46
0x115e1cf ???
	../../gcc/rust/backend/rust-compile-expr.h:59
0x11661f3 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x11661f3 Rust::Compile::CompileExpr::visit(Rust::HIR::ArithmeticOrLogicalExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:146
0x11661f3 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x11661f3 Rust::Compile::CompileExpr::visit(Rust::HIR::ArithmeticOrLogicalExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:146
0x11661f3 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x11661f3 Rust::Compile::CompileExpr::visit(Rust::HIR::ArithmeticOrLogicalExpr&)
	../../gcc/rust/backend/rust-compile-expr.cc:146
0x1162ab6 Rust::Compile::CompileExpr::Compile(Rust::HIR::Expr&, Rust::Compile::Context*)
	../../gcc/rust/backend/rust-compile-expr.cc:48
0x118e72f Rust::Compile::HIRCompileBase::compile_constant_item(unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:869
0x118ee84 Rust::Compile::HIRCompileBase::compile_constant_expr(Rust::Compile::Context*, unsigned int, Rust::TyTy::BaseType*, Rust::TyTy::BaseType*, Rust::Resolver::CanonicalPath const&, Rust::HIR::Expr&, unsigned long, unsigned long)
	../../gcc/rust/backend/rust-compile-base.cc:573
0x118ee84 Rust::Compile::HIRCompileBase::query_compile_const_expr(Rust::Compile::Context*, Rust::TyTy::BaseType*, Rust::HIR::Expr&)
	../../gcc/rust/backend/rust-compile-base.cc:588
0x109f700 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ArrayExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1111
0x109a314 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:50
0x10a9eb1 Rust::Resolver::TypeCheckStmt::visit(Rust::HIR::LetStmt&)
	../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:90
0x10a9fa3 Rust::Resolver::TypeCheckStmt::Resolve(Rust::HIR::Stmt&)
	../../gcc/rust/typecheck/rust-hir-type-check-stmt.cc:34
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions