Simplify match.

This commit is contained in:
Stephen Chung
2023-04-05 23:15:55 +08:00
parent 5eaa4c5240
commit df05f43460
5 changed files with 53 additions and 67 deletions

View File

@@ -259,17 +259,18 @@ impl Engine {
self.eval_fn_call_expr(global, caches, scope, this_ptr, x, *pos)
}
Expr::Variable(x, index, var_pos) => {
if index.is_none() && x.0.is_none() && x.3 == KEYWORD_THIS {
this_ptr
.ok_or_else(|| ERR::ErrorUnboundThis(*var_pos).into())
.cloned()
} else {
self.search_namespace(global, caches, scope, this_ptr, expr)
.map(Target::take_or_clone)
}
Expr::Variable(x, index, var_pos)
if index.is_none() && x.0.is_none() && x.3 == KEYWORD_THIS =>
{
this_ptr
.ok_or_else(|| ERR::ErrorUnboundThis(*var_pos).into())
.cloned()
}
Expr::Variable(..) => self
.search_namespace(global, caches, scope, this_ptr, expr)
.map(Target::take_or_clone),
Expr::InterpolatedString(x, _) => {
let mut concat = SmartString::new_const();