Skip to content

Commit 7033901

Browse files
committed
fix for parsing x() as identifier pattern
1 parent 5119597 commit 7033901

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,14 +2359,13 @@ pub impl Parser {
23592359
}
23602360
_ => {
23612361
let mut args: ~[@pat] = ~[];
2362-
let mut star_pat = false;
23632362
match *self.token {
23642363
token::LPAREN => match self.look_ahead(1u) {
23652364
token::BINOP(token::STAR) => {
23662365
// This is a "top constructor only" pat
23672366
self.bump(); self.bump();
2368-
star_pat = true;
23692367
self.expect(&token::RPAREN);
2368+
pat = pat_enum(enum_path, None);
23702369
}
23712370
_ => {
23722371
args = self.parse_unspanned_seq(
@@ -2377,23 +2376,21 @@ pub impl Parser {
23772376
),
23782377
|p| p.parse_pat(refutable)
23792378
);
2379+
pat = pat_enum(enum_path, Some(args));
23802380
}
23812381
},
2382-
_ => ()
2383-
}
2384-
// at this point, we're not sure whether it's a
2385-
// enum or a bind
2386-
if star_pat {
2387-
pat = pat_enum(enum_path, None);
2388-
}
2389-
else if vec::is_empty(args) &&
2390-
vec::len(enum_path.idents) == 1u {
2391-
pat = pat_ident(binding_mode,
2392-
enum_path,
2393-
None);
2394-
}
2395-
else {
2396-
pat = pat_enum(enum_path, Some(args));
2382+
_ => {
2383+
if vec::len(enum_path.idents)==1u {
2384+
// it could still be either an enum
2385+
// or an identifier pattern, resolve
2386+
// will sort it out:
2387+
pat = pat_ident(binding_mode,
2388+
enum_path,
2389+
None);
2390+
} else {
2391+
pat = pat_enum(enum_path, Some(args));
2392+
}
2393+
}
23972394
}
23982395
}
23992396
}

0 commit comments

Comments
 (0)