Skip to content

ICE in try access a field of enum #23253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tioover opened this issue Mar 10, 2015 · 4 comments
Closed

ICE in try access a field of enum #23253

tioover opened this issue Mar 10, 2015 · 4 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@tioover
Copy link

tioover commented Mar 10, 2015

enum Foo {
    Bar {a: usize},
}


fn main() {
    let foo = Foo::Bar {a: 42};
    foo.a += 1;
}
Project ❯ RUST_BACKTRACE=1 rustc test.rs                                       ⏎
test.rs:8:5: 8:10 error: attempted access of field `a` on type `Foo`, but no field with that name was found
test.rs:8     foo.a += 1;
              ^~~~~
error: internal compiler error: ID not mapped to struct fields: enum Foo::Foo (id=4)
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:189

stack backtrace:
   1:        0x11264126d - sys::backtrace::write::h2f0eebf22a012f95KDA
   2:        0x11266ac34 - panicking::on_panic::h2d130f87f4af87adMsJ
   3:        0x11259c279 - rt::unwind::begin_unwind_inner::h1a1f64f2e0909849ibJ
   4:        0x111d4fd1e - rt::unwind::begin_unwind::h15175361780993285323
   5:        0x111d5064c - diagnostic::Handler::bug::h23435f9fdd104385KdE
   6:        0x10f7f8239 - middle::ty::lookup_struct_fields::hcfa63d5d455b1d22947
   7:        0x10ef7eb5c - check::check_expr_with_unifier::suggest_field_names::h2d7823337504373bcBq
   8:        0x10ef55b52 - check::check_expr_with_unifier::check_field::h299378f7d98e57056uq
   9:        0x10ef795d5 - check::check_expr_with_unifier::h5233460879988672432
  10:        0x10ef4b892 - check::check_expr_with_unifier::check_binop::h83d5b23b6776607eXgq
  11:        0x10ef73b06 - check::check_expr_with_unifier::h10683062894677546464
  12:        0x10ef37265 - check::check_block_with_expected::h98c4be472f33b682P2r
  13:        0x10ef1ead9 - check::check_fn::h75f3466823e4699afmn
  14:        0x10ef348e0 - check::check_bare_fn::heef299f5e2ff7015Vbn
  15:        0x10ef2cec8 - check::check_item::hd818d764a5174b83zun
  16:        0x10eff0f92 - check_crate::closure.35692
  17:        0x10efecb40 - check_crate::hf2d34adf6a37b8a3hfC
  18:        0x10ed3c0da - driver::phase_3_run_analysis_passes::h19eafcd6b91dc30emGa
  19:        0x10ed213d3 - driver::compile_input::hc0fa04a0185cf5d5Nba
  20:        0x10edeebf6 - run_compiler::h4fb68ba30fa1fbedG6b
  21:        0x10edec2e0 - thunk::F.Invoke<A, R>::invoke::h6674872152586368688
  22:        0x10edeae1f - rt::unwind::try::try_fn::h6409312628170534502
  23:        0x1126e4ca8 - rust_try_inner
  24:        0x1126e4c95 - rust_try
  25:        0x10edeb63f - thunk::F.Invoke<A, R>::invoke::h5915792664557581551
  26:        0x1126563e2 - sys::thread::thread_start::he449e30ddbe8a26532E
  27:     0x7fff91099267 - _pthread_body
  28:     0x7fff910991e4 - _pthread_start
@tioover tioover changed the title ICE in access a field of enum ICE in try access a field of enum Mar 10, 2015
@shepmaster
Copy link
Member

Slightly smaller example:

enum Foo { Bar }

fn main() {
    Foo::Bar.a;
}

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 10, 2015
@frewsxcv
Copy link
Member

Running with

~/Downloads $ rustc --version
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)

@tioover's code block

~/Downloads $ rustc test.rs
test.rs:8:5: 8:10 error: attempted access of field `a` on type `Foo`, but no field with that name was found
test.rs:8     foo.a += 1;
              ^~~~~
error: aborting due to previous error

@shepmaster's code block

~/Downloads $ rustc test.rs
test.rs:4:5: 4:15 error: attempted access of field `a` on type `Foo`, but no field with that name was found
test.rs:4     Foo::Bar.a;
              ^~~~~~~~~~
error: aborting due to previous error

I can't reproduce the ICE. Can this be closed?

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 25, 2015
jooert added a commit to jooert/rust that referenced this issue Apr 25, 2015
@jooert
Copy link
Contributor

jooert commented Apr 27, 2015

Tests added in #24828.

@bombless
Copy link
Contributor

Should be closed now, @tioover

@tioover tioover closed this as completed Apr 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

7 participants