diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-21 14:55:54 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-10-21 14:55:54 +0200 |
| commit | b0a72ee06a5ac28e18b8a549132eda23e32856c9 (patch) | |
| tree | 7955960f725deb2660d53967714417dc62f95550 /src/comp | |
| parent | 3b5b93221e1bf35b48dc5fd040f0086892704ca5 (diff) | |
| download | rust-b0a72ee06a5ac28e18b8a549132eda23e32856c9.tar.gz rust-b0a72ee06a5ac28e18b8a549132eda23e32856c9.zip | |
Be more careful when parsing block calls
Previously, the parser would try to interpret this as a block call:
if true {} // No semicolon
{|i, am, a, block|};
Which, though unlikely, might come up in practice.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/syntax/parse/parser.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 8f632165772..4df2b6ab3cf 100644 --- a/src/comp/syntax/parse/parser.rs +++ b/src/comp/syntax/parse/parser.rs @@ -1585,7 +1585,8 @@ fn parse_source_stmt(p: parser) -> @ast::stmt { // Remainder are line-expr stmts. let e = parse_expr(p); // See if it is a block call - if p.peek() == token::LBRACE && is_bar(p.look_ahead(1u)) { + if expr_has_value(e) && p.peek() == token::LBRACE && + is_bar(p.look_ahead(1u)) { p.bump(); let blk = parse_fn_block_expr(p); alt e.node { |
