diff options
author | bravomikekilo <[email protected]> | 2019-08-03 12:57:07 +0100 |
---|---|---|
committer | bravomikekilo <[email protected]> | 2019-08-03 12:57:07 +0100 |
commit | 562359d706fc9365c20ee8a6785b93bb48a0e07a (patch) | |
tree | 87a1aeb528149c255fa0e774f08303980dbe9338 /crates/ra_parser/src/grammar | |
parent | 0ca30b6c4bb717e3cc54bfc98ffaa7a6d8c2cdfd (diff) |
fix block parse problem
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions.rs | 13 |
1 files changed, 6 insertions, 7 deletions
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( | |||
360 | } | 360 | } |
361 | _ => { | 361 | _ => { |
362 | let (lhs, blocklike) = atom::atom_expr(p, r)?; | 362 | let (lhs, blocklike) = atom::atom_expr(p, r)?; |
363 | return Some(( | 363 | return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block()))); |
364 | postfix_expr(p, lhs, !(r.prefer_stmt && blocklike.is_block())), | ||
365 | blocklike, | ||
366 | )); | ||
367 | } | 364 | } |
368 | }; | 365 | }; |
369 | expr_bp(p, r, 255, dollar_lvl); | 366 | expr_bp(p, r, 255, dollar_lvl); |
@@ -376,8 +373,9 @@ fn postfix_expr( | |||
376 | // Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple | 373 | // Calls are disallowed if the type is a block and we prefer statements because the call cannot be disambiguated from a tuple |
377 | // E.g. `while true {break}();` is parsed as | 374 | // E.g. `while true {break}();` is parsed as |
378 | // `while true {break}; ();` | 375 | // `while true {break}; ();` |
376 | mut block_like: BlockLike, | ||
379 | mut allow_calls: bool, | 377 | mut allow_calls: bool, |
380 | ) -> CompletedMarker { | 378 | ) -> (CompletedMarker, BlockLike) { |
381 | loop { | 379 | loop { |
382 | lhs = match p.current() { | 380 | lhs = match p.current() { |
383 | // test stmt_postfix_expr_ambiguity | 381 | // test stmt_postfix_expr_ambiguity |
@@ -417,9 +415,10 @@ fn postfix_expr( | |||
417 | T![as] => cast_expr(p, lhs), | 415 | T![as] => cast_expr(p, lhs), |
418 | _ => break, | 416 | _ => break, |
419 | }; | 417 | }; |
420 | allow_calls = true | 418 | allow_calls = true; |
419 | block_like = BlockLike::NotBlock; | ||
421 | } | 420 | } |
422 | lhs | 421 | (lhs, block_like) |
423 | } | 422 | } |
424 | 423 | ||
425 | // test call_expr | 424 | // test call_expr |