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.
This commit is contained in:
Marijn Haverbeke 2011-10-21 14:55:54 +02:00
parent 3b5b93221e
commit b0a72ee06a

View File

@ -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 {