From b0a72ee06a5ac28e18b8a549132eda23e32856c9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 21 Oct 2011 14:55:54 +0200 Subject: [PATCH] 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. --- src/comp/syntax/parse/parser.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs index 8f632165772b..4df2b6ab3cff 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 {