Skip to content

Fix incorrect non-exhaustive matching for fixed length vecs #8386

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

Merged
merged 1 commit into from
Aug 11, 2013

Conversation

stepancheg
Copy link
Contributor

Code like this is fixed now:

fn foo(p: [u8, ..4]) {
    match p {
        [a, b, c, d] => {}
    };
}

Invalid constructors are not reported as errors yet:

fn foo(p: [u8, ..4]) {
    match p {
        [_, _, _] => {} // this should be error
        [_, _, _, _, _, .._] => {} // and this
        _ => {}
    }
}

Issue #8311 is partially fixed: fixed-length vectors in let statement are not yet allowed.

Code like this is fixed now:

```
fn foo(p: [u8, ..4]) {
    match p {
        [a, b, c, d] => {}
    };
}
```

Invalid constructors are not reported as errors yet:

```
fn foo(p: [u8, ..4]) {
    match p {
        [_, _, _] => {} // this should be error
        [_, _, _, _, _, .._] => {} // and this
        _ => {}
    }
}
```

Issue rust-lang#8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:

```
let [a, b, c] = [1, 2, 3]; // still fails
```
@huonw
Copy link
Member

huonw commented Aug 8, 2013

This looks cool! Does it fix it for let too? I.e. let [a,b,c] = length_three().

@stepancheg
Copy link
Contributor Author

@huonw no, it is the same:

tmp.rs:4:8: 4:17 error: refutable pattern in local binding
tmp.rs:4     let [a, b, c] = length_three();
                 ^~~~~~~~~
error: aborting due to previous error

It is a separate issue.

@bstrie
Copy link
Contributor

bstrie commented Aug 8, 2013

Wow, very cool! But if this commit doesn't also fix this for let patterns, then please revise your commit message to remove the "Fixes" reference to #8311, because otherwise Github will close that issue automatically when the commit hits master.

@stepancheg
Copy link
Contributor Author

@bstrie updated commit comment.

bors added a commit that referenced this pull request Aug 10, 2013
This merges these PR together:

#8430: r=thestinger 
#8370: r=thestinger
#8386: r=bstrie
#8388: r=thestinger
#8390: r=graydon
#8394: r=graydon
#8402: r=thestinger
#8403: r=catamorphism
@bors bors merged commit 828bfb2 into rust-lang:master Aug 11, 2013
@stepancheg stepancheg deleted the vec-exh branch August 11, 2013 03:37
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 10, 2022
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

Successfully merging this pull request may close these issues.

4 participants