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 bug with misspelt enum name #35645

Closed
ns-sundar opened this issue Aug 13, 2016 · 2 comments
Closed

Compiler bug with misspelt enum name #35645

ns-sundar opened this issue Aug 13, 2016 · 2 comments

Comments

@ns-sundar
Copy link

ns-sundar commented Aug 13, 2016

enum Token {
Num(i32),
AddSub(char),
MulDiv(char),
LeftParen(char),
RightParen(char)
}

fn main() {
println!("Hello World\n");

}

[allow(dead_code)]

fn postfix_from_infix(infix: Vec) -> Vec {
let postfix = Vec::::new();

for token in infix {
match token {
Toekn::LeftParen(_) => break,
_ => {}
}
}

postfix
}

C:\UserData\Tech\Rust\expr\src>cargo run -- "527 + 35*2"
   Compiling expr v0.1.0 (file:///C:/UserData/Tech/Rust/expr)
main.rs:20:10: 20:26 error: failed to resolve. Use of undeclared type or module
`Toekn` [E0433]
main.rs:20          Toekn::LeftParen(_) => break,
                    ^~~~~~~~~~~~~~~~
main.rs:20:10: 20:26 help: run `rustc --explain E0433` to see a detailed explana
tion
main.rs:20:10: 20:29 error: internal compiler error: ../src/librustc\middle\mem_
categorization.rs:1262: enum pattern didn't resolve to enum or struct None
main.rs:20          Toekn::LeftParen(_) => break,
                    ^~~~~~~~~~~~~~~~~~~
**note: the compiler unexpectedly panicked. this is a bug.**
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/m
aster/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax\errors/mod.rs:545
note: Run with `RUST_BACKTRACE=1` for a backtrace.

error: Could not compile `expr`.

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

###################
I misspelt the enum Token as Toekn. The compiler panics.
C:\UserData\Tech\Rust\expr\src>rustc --version
rustc 1.10.0 (cfcb716cf 2016-07-03)
@petrochenkov
Copy link
Contributor

Fixed on beta/nightly.

Working/minimized reproduction:

enum Token {
    LeftParen(char),
    RightParen(char),
}

#[allow(dead_code)]
fn postfix_from_infix(infix: Vec<Token>) {
    for token in infix {
        match token {
            Toekn::LeftParen(_) => {},
            _ => {}
        }
    }
}

fn main() {}

@nagisa
Copy link
Member

nagisa commented Aug 13, 2016

Duplicate of #33293.

@arielb1 arielb1 closed this as completed Aug 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants