Files
ladybird/Tests/LibJS/AST/input/eval-indirect.js
Andreas Kling f7c961136f Tests/LibJS: Add AST dump test cases
Add 39 test cases exercising AST dump output and scope analysis.
Tests cover local/global identifier marking, eval/with poisoning,
destructuring, closures, hoisting, classes, generators, and more.
2026-02-10 02:05:20 +01:00

31 lines
596 B
JavaScript

// Indirect eval (not a direct call to `eval`) does NOT poison scope.
function indirect_eval() {
let x = 1;
(0, eval)("x");
return x;
}
// Assigning eval to a variable and calling it is also indirect.
function eval_alias() {
let x = 1;
var e = eval;
e("x");
return x;
}
// eval as a method call is indirect.
function eval_method() {
let x = 1;
var obj = { eval };
obj.eval("x");
return x;
}
// Calling something NAMED eval that isn't the global eval.
function local_eval_name() {
let x = 1;
let eval = s => s;
eval("x");
return x;
}