Allow trailing comma in vectors. Closes #2482.

This commit is contained in:
Lindsey Kuper 2012-06-12 12:05:23 -07:00
parent bffb7db8ae
commit 8a730a255d
3 changed files with 14 additions and 1 deletions

View File

@ -805,7 +805,7 @@ class parser {
self.bump();
let mutbl = self.parse_mutability();
let es = self.parse_seq_to_end(
token::RBRACKET, seq_sep_trailing_disallowed(token::COMMA),
token::RBRACKET, seq_sep_trailing_allowed(token::COMMA),
{|p| p.parse_expr()});
hi = self.span.hi;
ex = expr_vec(es, mutbl);

View File

@ -0,0 +1,3 @@
fn main() {
let v = [,]; //! ERROR unexpected token: ','
}

View File

@ -0,0 +1,10 @@
// Issue #2482.
fn main() {
let v1: [int] = [10, 20, 30,];
let v2: [int] = [10, 20, 30];
assert (v1[2] == v2[2]);
let v3: [int] = [10,];
let v4: [int] = [10];
assert (v3[0] == v4[0]);
}