Fix bug in parsing index chains.

This commit is contained in:
Stephen Chung
2023-04-19 23:17:54 +08:00
parent 0699f47ff9
commit fb88b79178
3 changed files with 31 additions and 8 deletions

View File

@@ -1728,6 +1728,9 @@ impl Engine {
) -> ParseResult<Expr> {
let mut settings = settings;
// Break just in case `lhs` is `Expr::Dot` or `Expr::Index`
let mut parent_options = ASTFlags::BREAK;
// Tail processing all possible postfix operators
loop {
let (tail_token, ..) = input.peek().expect(NEVER_ENDS);
@@ -1842,13 +1845,16 @@ impl Engine {
let rhs =
self.parse_primary(input, state, lib, settings.level_up()?, options)?;
Self::make_dot_expr(state, expr, rhs, ASTFlags::empty(), op_flags, tail_pos)?
Self::make_dot_expr(state, expr, rhs, parent_options, op_flags, tail_pos)?
}
// Unknown postfix operator
(expr, token) => {
unreachable!("unknown postfix operator '{}' for {:?}", token, expr)
}
}
};
// The chain is now extended
parent_options = ASTFlags::empty();
}
// Cache the hash key for namespace-qualified variables