From 562359d706fc9365c20ee8a6785b93bb48a0e07a Mon Sep 17 00:00:00 2001 From: bravomikekilo Date: Sat, 3 Aug 2019 19:57:07 +0800 Subject: fix block parse problem --- crates/ra_parser/src/grammar/expressions.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'crates/ra_parser') diff --git a/crates/ra_parser/src/grammar/expressions.rs b/crates/ra_parser/src/grammar/expressions.rs index 3e49e70c7..26f184785 100644 --- a/crates/ra_parser/src/grammar/expressions.rs +++ b/crates/ra_parser/src/grammar/expressions.rs @@ -360,10 +360,7 @@ fn lhs( } _ => { let (lhs, blocklike) = atom::atom_expr(p, r)?; - return Some(( - postfix_expr(p, lhs, !(r.prefer_stmt && blocklike.is_block())), - blocklike, - )); + return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block()))); } }; expr_bp(p, r, 255, dollar_lvl); @@ -376,8 +373,9 @@ fn postfix_expr( // Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple // E.g. `while true {break}();` is parsed as // `while true {break}; ();` + mut block_like: BlockLike, mut allow_calls: bool, -) -> CompletedMarker { +) -> (CompletedMarker, BlockLike) { loop { lhs = match p.current() { // test stmt_postfix_expr_ambiguity @@ -417,9 +415,10 @@ fn postfix_expr( T![as] => cast_expr(p, lhs), _ => break, }; - allow_calls = true + allow_calls = true; + block_like = BlockLike::NotBlock; } - lhs + (lhs, block_like) } // test call_expr -- cgit v1.2.3