Warn against eval in method-call style.
This commit is contained in:
parent
05bad53011
commit
e7cc403381
@ -680,6 +680,14 @@ impl Engine {
|
|||||||
Ok(self.map_type_name(args[0].type_name()).to_string().into())
|
Ok(self.map_type_name(args[0].type_name()).to_string().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eval
|
||||||
|
KEYWORD_EVAL if args.len() == 1 && !self.has_override(fn_lib, KEYWORD_EVAL) => {
|
||||||
|
Err(Box::new(EvalAltResult::ErrorRuntime(
|
||||||
|
"'eval' should not be called in method style. Try eval(...);".into(),
|
||||||
|
pos,
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
// Map property access?
|
// Map property access?
|
||||||
if let Some(prop) = extract_prop_from_getter(fn_name) {
|
if let Some(prop) = extract_prop_from_getter(fn_name) {
|
||||||
@ -1487,11 +1495,11 @@ impl Engine {
|
|||||||
Stmt::Expr(expr) => {
|
Stmt::Expr(expr) => {
|
||||||
let result = self.eval_expr(scope, fn_lib, expr, level)?;
|
let result = self.eval_expr(scope, fn_lib, expr, level)?;
|
||||||
|
|
||||||
Ok(if !matches!(expr.as_ref(), Expr::Assignment(_, _, _)) {
|
Ok(if let Expr::Assignment(_, _, _) = *expr.as_ref() {
|
||||||
result
|
|
||||||
} else {
|
|
||||||
// If it is an assignment, erase the result at the root
|
// If it is an assignment, erase the result at the root
|
||||||
().into()
|
().into()
|
||||||
|
} else {
|
||||||
|
result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user