Skip to content

Matching fixed-size vectors requires handling vectors of arbitrary size #7045

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
ghost opened this issue Jun 10, 2013 · 1 comment
Closed

Comments

@ghost
Copy link

ghost commented Jun 10, 2013

I'm trying to use pattern matching with fixed-size vectors, like this:

fn main() {
    match [3, 5] {
        [a, b] => println("ok")
    };
}

However, this doesn't compile (I'm using 0.6 on Windows):

error: non-exhaustive patterns: vectors of length 0 not covered

After adding a wildcard the program compiles...

fn main() {
    match [3, 5] {
        [a, b] => println("ok"),
        _ => ()
    };
}

... which I think it shouldn't, since that last pattern is (or should be) unreachable. When replacing the fixed-size vector with a tuple, it certainly is:

fn main() {
    match (3, 5) {
        (a, b) => println("ok"),
        _ => ()
    };
}
error: unreachable pattern
@huonw
Copy link
Member

huonw commented Jul 14, 2013

Hi, it looks like #7784 was accidentally filed too; I'm closing this one as a dup because that issue uses the appropriate jargon, which helps when searching.

@huonw huonw closed this as completed Jul 14, 2013
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