Skip to content

Incorrect codegen with shadowed constants in a match arm #27077

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
Aatch opened this issue Jul 17, 2015 · 1 comment
Closed

Incorrect codegen with shadowed constants in a match arm #27077

Aatch opened this issue Jul 17, 2015 · 1 comment
Labels
A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aatch
Copy link
Contributor

Aatch commented Jul 17, 2015

From @eefriedman's comment in #27033:

fn main() {
    const C: u8 = 3;
    match 1 {
        C @ 2 => { println!("{}", C); }
        _ => {}
    };
}
<anon>:4:9: 4:14 warning: unused variable: `C`, #[warn(unused_variables)] on by default
<anon>:4         C @ 2 => { println!("{}", C); }
                 ^~~~~
Switch constants must all be same type as switch value!
  switch i32 %3, label %match_else [
    i8 3, label %match_case
  ]
LLVM ERROR: Broken function found, compilation aborted!
playpen: application terminated with error code 1

Not sure how this is happening and the code should be rejected as in #27033, but it does indicate that something in the compiler is probably broken.

cc @rust-lang/compiler

@Aatch Aatch added A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 17, 2015
@arielb1
Copy link
Contributor

arielb1 commented Jul 28, 2015

This is a wrong-codegen bug:

fn f(x: Option<u32>) {
    const C: Option<u32> = None;
    match x {
        C @ Some(x) => { println!("{}", x); }
        _ => {}
    }
}
fn main() { f(None) }

arielb1 pushed a commit to arielb1/rust that referenced this issue Jul 28, 2015
as this breaks code that worked under some conditions, this is a
[breaking-change]

Fixes rust-lang#27033
Fixes rust-lang#27077
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants