Skip to content

Compiler panic on using a nonexistent field of a struct #20829

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
CrystalGamma opened this issue Jan 9, 2015 · 0 comments · Fixed by #20897
Closed

Compiler panic on using a nonexistent field of a struct #20829

CrystalGamma opened this issue Jan 9, 2015 · 0 comments · Fixed by #20897
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@CrystalGamma
Copy link

While writing my own toy compiler, I deleted a field from a struct, and then ran the compiler hoping it would point out where I missed a use.

This made rustc crash:

$ RUST_BACKTRACE=1 cargo test
Compiling compile v0.0.1 (file:///home/jona/src/compile)
/home/jona/src/compile/src/main.rs:107:7: 107:17 error: attempted access of field `types` on type `&mut Function`, but no field with that name was found
/home/jona/src/compile/src/main.rs:107                      func.types[func.values[idx].typ] = superimpose(&func.values[idx].typ, &typ).unwrap();
                                        ^~~~~~~~~~
error: internal compiler error: no type for node 2838: expr func.values[idx].typ (id=2838) in fcx 0x7feebbfecbb8
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:182

stack backtrace:
1:     0x7feec3bdf850 - sys::backtrace::write::h5b05e7b061a35107Czt
2:     0x7feec3c01a60 - failure::on_fail::h1e9b7e3de59488d1aPz
3:     0x7feec3b6f5e0 - rt::unwind::begin_unwind_inner::h23dcfb4c37870bd62tz
4:     0x7feebe95d460 - rt::unwind::begin_unwind::h8180555736548804672
5:     0x7feebe95dd10 - diagnostic::Handler::bug::hfea99a1512d774b6tWF
6:     0x7feec1ec70d0 - session::Session::bug::hda4aef05452f83daiRq
7:     0x7feec3314f80 - check::FnCtxt<'a, 'tcx>::node_ty::hd15e5fbb39eb4572xcm
8:     0x7feec3326590 - check::writeback::WritebackCx<'cx, 'tcx>::visit_node_id::h8a2bfc07a98e1301bEb
9:     0x7feec3324e30 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::hd8ad1eaead247978bub
10:     0x7feec3326490 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_block::hdcb765d26faad3efqvb
11:     0x7feec3324e30 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_expr::hd8ad1eaead247978bub
12:     0x7feec3326490 - check::writeback::WritebackCx<'cx, 'tcx>.Visitor<'v>::visit_block::hdcb765d26faad3efqvb
13:     0x7feec33ab360 - check::check_bare_fn::h12b646cb07f4b492H3j
14:     0x7feec33a2ad0 - check::check_item::h45ea87c7d5c5cf84umk
15:     0x7feec3470b30 - check_crate::unboxed_closure.30617
16:     0x7feec346b670 - check_crate::hdbcb36eaa379a57c23x
17:     0x7feec41349c0 - driver::phase_3_run_analysis_passes::h8c55e45fcfc1c7aegwa
18:     0x7feec411d350 - driver::compile_input::h04aea004c559b910xba
19:     0x7feec41ecfe0 - monitor::unboxed_closure.22497
20:     0x7feec41ece40 - thunk::F.Invoke<A, R>::invoke::h11849311349984608396
21:     0x7feec41ebbc0 - rt::unwind::try::try_fn::h13617610205470131813
22:     0x7feec3c676c0 - rust_try_inner
23:     0x7feec3c676b0 - rust_try
24:     0x7feec41ebeb0 - thunk::F.Invoke<A, R>::invoke::h14452289732390470265
25:     0x7feec3bef910 - sys::thread::thread_start::h93b0d38960a9fcacqrw
26:     0x7feebe16f250 - start_thread
27:     0x7feec3820219 - clone
28:                0x0 - <unknown>

Could not compile `compile`.

To learn more, run the command again with --verbose.

Source is in https://github.com/CrystalGamma/oxide/blob/8c3e3ddb4dfb4facfda443e8a34d09b881e43d31/src/main.rs

Compiler version:
rustc 1.0.0-nightly (44a287e 2015-01-08 17:03:40 -0800)
binary: rustc
commit-hash: 44a287e
commit-date: 2015-01-08 17:03:40 -0800
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

Hope I could help.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 9, 2015
barosl added a commit to barosl/rust that referenced this issue Jan 11, 2015
If the type of a node cannot be determined due to a previous type error,
a "no type for node" ICE occurs. This commit makes it return ty_err
instead in such a case.

Fixes rust-lang#20401.
Fixes rust-lang#20506.
Fixes rust-lang#20614.
Fixes rust-lang#20752.
Fixes rust-lang#20829.
Fixes rust-lang#20846.
Fixes rust-lang#20885.
Fixes rust-lang#20886.
bors added a commit that referenced this issue Jan 12, 2015
If the type of a node cannot be determined due to a previous type error, a `no type for node` ICE occurs. This commit makes it return `ty_err` instead in such a case.

Fixes #20401.
Fixes #20506.
Fixes #20614.
Fixes #20752.
Fixes #20829.
Fixes #20846.
Fixes #20885.
Fixes #20886.
Fixes #20952.
Fixes #20970.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants