Allow block expressions.

This commit is contained in:
Stephen Chung
2020-03-07 10:39:00 +08:00
parent 473e40e8a4
commit 22cb69a16b
2 changed files with 15 additions and 0 deletions

View File

@@ -544,10 +544,15 @@ impl Engine<'_> {
Expr::Identifier(id, pos) => {
Self::search_scope(scope, id, Ok, *pos).map(|(_, val)| val)
}
// lhs[idx_expr]
Expr::Index(lhs, idx_expr, idx_pos) => self
.eval_index_expr(scope, lhs, idx_expr, *idx_pos)
.map(|(_, _, _, x)| x),
// Statement block
Expr::Block(block, _) => self.eval_stmt(scope, block),
// lhs = rhs
Expr::Assignment(lhs, rhs, _) => {
let rhs_val = self.eval_expr(scope, rhs)?;