Skip to content

rustc: "error: internal compiler error: no type for node 41: local x (id=41) in fcx 0x7ff2ddbade98" #13624

Closed

Description

@a-p-

Versions:

$ rustc -v
rustc 0.11-pre (c7553ea 2014-04-19 02:11:30 -0700)
host: x86_64-unknown-linux-gnu
$ uname -a
Linux test 3.13-1-amd64 #1 SMP Debian 3.13.7-1 (2014-03-25) x86_64 GNU/Linux
$ 

Code to reproduce the ICE:

#![feature(struct_variant)]

mod a {
  pub enum Enum {  
    EnumStructVariant { x: u8, y: u8, z: u8 }
  }

  pub fn get_enum_struct_variant() {
    EnumStructVariant { x: 1, y: 2, z: 3 }
  }
}

mod b {
  #[cfg(test)]
  mod test {
    use a;

    #[test]
    fn test_enum_struct_variant() {
      let enum_struct_variant = ::a::get_enum_struct_variant();
      match enum_struct_variant {
        a::EnumStructVariant { x, y, z } => {
          assert_eq!(1, x);
          assert_eq!(2, y);
          assert_eq!(3, z);
        },
        _ => fail!(~"no match")  
      }
    }
  }
}

Compilation output:

$ RUST_BACKTRACE=1 rustc --test test.rs 
test.rs:9:5: 9:43 error: mismatched types: expected `()` but found `a::Enum` (expected () but found enum a::Enum)
test.rs:9     EnumStructVariant { x: 1, y: 2, z: 3 }
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:22:9: 22:41 error: mismatched types: expected `()` but found a structure pattern
test.rs:22         a::EnumStructVariant { x, y, z } => {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: internal compiler error: no type for node 41: local x (id=41) in fcx 0x7fafd3fcbe98
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /tmp/rust/src/libsyntax/diagnostic.rs:155
stack backtrace:
   1:     0x7fafd710fe80 - rt::backtrace::imp::write::h05ad43ec7787e135wta::v0.11.pre
   2:     0x7fafd7071290 - rt::unwind::begin_unwind_inner::hac94da1cdf3e8a6dZ39::v0.11.pre
   3:     0x7fafd5ae2fb0 - rt::unwind::begin_unwind::h17308229952267765168::v0.11.pre
   4:     0x7fafd5ae4010 - diagnostic::Handler::bug::had96abefee4d50728Xb::v0.11.pre
   5:     0x7fafd7ac6300 - driver::session::Session::bug::h8052d5399f7b4d89iDg::v0.11.pre
   6:     0x7fafd7ce9690 - middle::typeck::check::FnCtxt$LT$$x27a$GT$::node_ty::h266c1c837d478b69KF8::v0.11.pre
   7:     0x7fafd7d09780 - middle::typeck::check::writeback::resolve_type_vars_for_node::hbc48b7050f0443e3Eh2::v0.11.pre
   8:     0x7fafd7d10420 - middle::typeck::check::writeback::visit_pat::haba75e8fd613010cQA2::v0.11.pre
   9:     0x7fafd7d10420 - middle::typeck::check::writeback::visit_pat::haba75e8fd613010cQA2::v0.11.pre
  10:     0x7fafd7d0fd50 - visit::walk_arm::h7056839743020299270::v0.11.pre
  11:     0x7fafd7d0eaf0 - middle::typeck::check::writeback::visit_expr::h3075d0f7ca507c5fGy2::v0.11.pre
  12:     0x7fafd7d100f0 - visit::walk_block::h2390430812655566266::v0.11.pre
  13:     0x7fafd7d13030 - middle::typeck::check::writeback::resolve_type_vars_in_fn::hfeaf21e766baaf3fLQ2::v0.11.pre
  14:     0x7fafd7d59930 - middle::typeck::check::check_bare_fn::he5890947b73331a2Ih7::v0.11.pre
  15:     0x7fafd7d54d10 - middle::typeck::check::check_item::h85092b1644b4d4beQz7::v0.11.pre
  16:     0x7fafd7d566e0 - visit::walk_item::h8774069490031190215::v0.11.pre
  17:     0x7fafd7d566e0 - visit::walk_item::h8774069490031190215::v0.11.pre
  18:     0x7fafd7d59810 - middle::typeck::check::check_item_types::h1b2aba05358d4238ih7::v0.11.pre
  19:     0x7fafd7e987d0 - util::common::time::h1348476385218534042::v0.11.pre
  20:     0x7fafd7e971a0 - middle::typeck::check_crate::h043615a3c22fd0dcfnu::v0.11.pre
  21:     0x7fafd82a8e60 - driver::driver::phase_3_run_analysis_passes::h1b3684c72fd5ff792Pe::v0.11.pre
  22:     0x7fafd82af500 - driver::driver::compile_input::h04718ee069976ad3Xef::v0.11.pre
  23:     0x7fafd82d3b20 - run_compiler::h9b85866479b94c45cOm::v0.11.pre
  24:     0x7fafd82eb3f0 - main_args::closure.91906
  25:     0x7fafd82e9960 - monitor::closure.91784
  26:     0x7fafd82e53a0 - task::TaskBuilder::try::closure.91550
  27:     0x7fafda08ada0 - task::spawn_opts::closure.7776
  28:     0x7fafd710af50 - rt::task::Task::run::closure.39968
  29:     0x7fafd7116be0 - rust_try
  30:     0x7fafd710ad90 - rt::task::Task::run::h484ea9de608dc658uU7::v0.11.pre
  31:     0x7fafda08abb0 - task::spawn_opts::closure.7749
  32:     0x7fafd710ea00 - rt::thread::thread_start::h5274526c2bf07fc4fz8::v0.11.pre
  33:     0x7fafd6a49fa0 - start_thread
  34:     0x7fafd6d44a09 - __clone
  35:                0x0 - <unknown>

$ 

Activity

  1. michaelsproul commented on Aug 12, 2014

    @michaelsproul
    Contributor

    That code example fails to compile, but it's because the function signature for get_enum_struct_variant is wrong. It should be:

    pub fn get_enum_struct_variant() -> Enum;
    

    When you make that change and make the struct fields public, the code compiles fine. Without the change I also didn't see any internal compiler errors.

    Rust Version: 0.12.0-pre-nightly, a1429bc, Linux x86_64

  2. alexcrichton commented on Aug 26, 2014

    @alexcrichton
    Member

    Flagging as needstest (not sure if one is checked in already)

  3. added a commit that references this issue on Nov 23, 2022
  4. added a commit that references this issue on Jan 28, 2025
    8f257c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions