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

incorrect pattern match #15129

Closed
dwrensha opened this issue Jun 23, 2014 · 0 comments
Closed

incorrect pattern match #15129

dwrensha opened this issue Jun 23, 2014 · 0 comments

Comments

@dwrensha
Copy link
Contributor

I observe the following behavior at 575710f

I expect the below program to fail to typecheck. It succeeds, however, and prints bogus output.

pub enum T {
    T1(()),
    T2(())
}

pub enum V {
    V1(int),
    V2(bool)
}

fn foo (x : (T, V)) {
    match x {
        (T1(()), V1(i))  => println!("T1(()), V1({})", i),
        (T2(()), V2(b))  => println!("T2(()), V2({})", b),

        // _ => ()
        // We need to handle the T1,V2 and T2,V1 cases, but if we add
        // the wildcard here, we get an "unreachable pattern" error.

    }
}


fn main () {

    foo((T1(()), V2(true)));
    // prints "T1(()), V1(0)"

    foo((T2(()), V1(99)));
    // prints "T2(()), V2(false)"
}

This is perhaps related to recent changes by @jakub- ?

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jun 25, 2014
Closes rust-lang#14482 (std: Bring back half of Add on String)
Closes rust-lang#15026 (librustc: Remove the fallback to `int` from typechecking.)
Closes rust-lang#15119 (Add more description to c_str::unwrap().)
Closes rust-lang#15120 (Add tests for rust-lang#12470 and rust-lang#14285)
Closes rust-lang#15122 (Remove the cheat sheet.)
Closes rust-lang#15126 (rustc: Always include the morestack library)
Closes rust-lang#15127 (Improve ambiguous pronoun.)
Closes rust-lang#15130 (Fix rust-lang#15129)
Closes rust-lang#15131 (Add the Guide, add warning to tutorial.)
Closes rust-lang#15134 (Xfailed tests for hygiene, etc.)
Closes rust-lang#15135 (core: Add stability attributes to Clone)
Closes rust-lang#15136 (Some minor improvements to core::bool)
Closes rust-lang#15137 (std: Add stability attributes to primitive numeric modules)
Closes rust-lang#15141 (Fix grammar in tutorial)
Closes rust-lang#15143 (Remove few FIXMEs)
Closes rust-lang#15145 (Avoid unnecessary temporary on assignments)
Closes rust-lang#15147 (Small improvements for metaprogramming)
Closes rust-lang#15153 (librustc: Check function argument patterns for legality of by-move)
Closes rust-lang#15154 (test: Add a test for regions, traits, and variance.)
Closes rust-lang#15159 (rustc: Don't register syntax crates twice)
Closes rust-lang#13816 (Stabilize version output for rustc and rustdoc)
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 17, 2023
…soc-ty, r=HKalbasi

Recover from missing associated items and generic const defaults

Fixes rust-lang#15129
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

1 participant