diff options
| author | John Clements <clements@racket-lang.org> | 2013-04-19 08:45:25 -0700 |
|---|---|---|
| committer | John Clements <clements@racket-lang.org> | 2013-04-28 09:51:15 -0700 |
| commit | 703390150a75abbe6fbacd6b6e3ae08c9a6f5e37 (patch) | |
| tree | 9708ca96e4ea3924eda74d925784deb9aa7fe87b /src/libsyntax/parse | |
| parent | 5119597dc6549e21d62ce7bae7b7418b3f8bf56e (diff) | |
| download | rust-703390150a75abbe6fbacd6b6e3ae08c9a6f5e37.tar.gz rust-703390150a75abbe6fbacd6b6e3ae08c9a6f5e37.zip | |
fix for parsing x() as identifier pattern
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index aa67bb23532..1ec7c91121d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2359,14 +2359,13 @@ pub impl Parser { } _ => { let mut args: ~[@pat] = ~[]; - let mut star_pat = false; match *self.token { token::LPAREN => match self.look_ahead(1u) { token::BINOP(token::STAR) => { // This is a "top constructor only" pat self.bump(); self.bump(); - star_pat = true; self.expect(&token::RPAREN); + pat = pat_enum(enum_path, None); } _ => { args = self.parse_unspanned_seq( @@ -2377,23 +2376,21 @@ pub impl Parser { ), |p| p.parse_pat(refutable) ); + pat = pat_enum(enum_path, Some(args)); } }, - _ => () - } - // at this point, we're not sure whether it's a - // enum or a bind - if star_pat { - pat = pat_enum(enum_path, None); - } - else if vec::is_empty(args) && - vec::len(enum_path.idents) == 1u { - pat = pat_ident(binding_mode, - enum_path, - None); - } - else { - pat = pat_enum(enum_path, Some(args)); + _ => { + if vec::len(enum_path.idents)==1u { + // it could still be either an enum + // or an identifier pattern, resolve + // will sort it out: + pat = pat_ident(binding_mode, + enum_path, + None); + } else { + pat = pat_enum(enum_path, Some(args)); + } + } } } } |
