Skip to content

ICE when indexing after accessing unknown field/method #20886

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

ICE when indexing after accessing unknown field/method #20886

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

Comments

@nstoddard
Copy link

The following code results in ICE:

fn main() {
  let a = "".x[0];
}
main.rs:2:11: 2:15 error: attempted access of field `x` on type `&'static str`, but no field with that name was found
main.rs:2   let a = "".x[0];
                    ^~~~
error: internal compiler error: no type for node 14: expr 0 (id=14) in fcx 0x47ec378
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>', C:\bot\slave\nightly-dist-rustc-win-64\build\src\libsyntax\diagnostic.rs:182
>rustc --version
rustc 1.0.0-nightly (44a287e6e 2015-01-08 17:03:40 -0800)

The error happens whenever 'x' is a unknown field or method; using a slice instead of an index also results in ICE.

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.
@kmcallister kmcallister added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 11, 2015
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