Skip to content

Compiler panics on typeof #29184

Closed
Closed
@matklad

Description

@matklad

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_.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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