2012-12-08 14:22:43 -06:00
|
|
|
fn main() {
|
|
|
|
let x: ~[(int, int)] = ~[];
|
|
|
|
match x {
|
|
|
|
[a, (2, 3), _] => (),
|
|
|
|
[(1, 2), (2, 3), b] => (), //~ ERROR unreachable pattern
|
|
|
|
_ => ()
|
|
|
|
}
|
|
|
|
|
Fix incorrect non-exhaustive matching for fixed length vecs
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 by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 13:07:24 -05:00
|
|
|
match ~[~"foo", ~"bar", ~"baz"] {
|
2013-05-24 21:35:29 -05:00
|
|
|
[a, _, _, .._] => { println(a); }
|
2012-12-08 14:22:43 -06:00
|
|
|
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
|
|
|
|
_ => { }
|
|
|
|
}
|
|
|
|
|
Fix incorrect non-exhaustive matching for fixed length vecs
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 by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 13:07:24 -05:00
|
|
|
match ~['a', 'b', 'c'] {
|
2012-12-08 14:22:43 -06:00
|
|
|
['a', 'b', 'c', .._tail] => {}
|
|
|
|
['a', 'b', 'c'] => {} //~ ERROR unreachable pattern
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|