Skip to content
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

Compiler panics on typeof #29184

Closed
matklad opened this issue Oct 20, 2015 · 0 comments
Closed

Compiler panics on typeof #29184

matklad opened this issue Oct 20, 2015 · 0 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@matklad
Copy link
Member

matklad commented Oct 20, 2015

If I compile

fn main() {
    let x: typeof(92) = 92;
}

I get

main.rs:2:12: 2:22 error: internal compiler error: typeof is reserved but unimplemented
main.rs:2     let x: typeof(92) = 92;
                     ^~~~~~~~~~
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>', ../src/libsyntax/diagnostic.rs:176

So here is a bug report :)

The cause of panic is astconv, so one solution may be to change span_bug to span_err!

But the root case is the parser, which accepts typeof, so one over solution would be to remove the case from the parser.

I don't now whether typeof variants should be removed from hir::Ty_ and ast::Ty_.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Oct 20, 2015
bors added a commit that referenced this issue Oct 23, 2015
Fixes #29184 

This adds an error message for the use of the reserved `typeof` keyword, instead of reporting an ICE.
Also adds a `compile-fail` test.

I chose to add a `span_err` instead of removing to parser code, as to preserve the reservation of `typeof`.
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

No branches or pull requests

2 participants