Skip to content

Commit b0a72ee

Browse files
committed
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.
1 parent 3b5b932 commit b0a72ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,8 @@ fn parse_source_stmt(p: parser) -> @ast::stmt {
15851585
// Remainder are line-expr stmts.
15861586
let e = parse_expr(p);
15871587
// See if it is a block call
1588-
if p.peek() == token::LBRACE && is_bar(p.look_ahead(1u)) {
1588+
if expr_has_value(e) && p.peek() == token::LBRACE &&
1589+
is_bar(p.look_ahead(1u)) {
15891590
p.bump();
15901591
let blk = parse_fn_block_expr(p);
15911592
alt e.node {

0 commit comments

Comments
 (0)