fix block parse problem
This commit is contained in:
@@ -360,10 +360,7 @@ fn lhs(
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let (lhs, blocklike) = atom::atom_expr(p, r)?;
|
let (lhs, blocklike) = atom::atom_expr(p, r)?;
|
||||||
return Some((
|
return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block())));
|
||||||
postfix_expr(p, lhs, !(r.prefer_stmt && blocklike.is_block())),
|
|
||||||
blocklike,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
expr_bp(p, r, 255, dollar_lvl);
|
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
|
// 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
|
// E.g. `while true {break}();` is parsed as
|
||||||
// `while true {break}; ();`
|
// `while true {break}; ();`
|
||||||
|
mut block_like: BlockLike,
|
||||||
mut allow_calls: bool,
|
mut allow_calls: bool,
|
||||||
) -> CompletedMarker {
|
) -> (CompletedMarker, BlockLike) {
|
||||||
loop {
|
loop {
|
||||||
lhs = match p.current() {
|
lhs = match p.current() {
|
||||||
// test stmt_postfix_expr_ambiguity
|
// test stmt_postfix_expr_ambiguity
|
||||||
@@ -417,9 +415,10 @@ fn postfix_expr(
|
|||||||
T![as] => cast_expr(p, lhs),
|
T![as] => cast_expr(p, lhs),
|
||||||
_ => break,
|
_ => break,
|
||||||
};
|
};
|
||||||
allow_calls = true
|
allow_calls = true;
|
||||||
|
block_like = BlockLike::NotBlock;
|
||||||
}
|
}
|
||||||
lhs
|
(lhs, block_like)
|
||||||
}
|
}
|
||||||
|
|
||||||
// test call_expr
|
// test call_expr
|
||||||
|
|||||||
Reference in New Issue
Block a user