mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Add bytecode tests verifying identifier resolution produces correct register-backed locals, global lookups, argument indices, and environment lookups for eval/with/captured cases. Add runtime tests for destructuring assignment patterns with expression defaults: class expressions (named/anonymous), function expressions, arrow functions, nested destructuring, eval in defaults, MemberExpression targets with setter functions, and class name scoping.
24 lines
534 B
JavaScript
24 lines
534 B
JavaScript
// Test that eval in scope chain prevents local variable promotion.
|
|
// Variables in a function with eval cannot be locals because eval
|
|
// may inject new bindings at runtime.
|
|
|
|
function with_eval() {
|
|
let x = 1;
|
|
eval("");
|
|
return x;
|
|
}
|
|
|
|
// But variables in a nested function (without eval itself) should
|
|
// still be promoted to locals, even if the outer function has eval.
|
|
function outer_eval() {
|
|
eval("");
|
|
function inner() {
|
|
let y = 2;
|
|
return y;
|
|
}
|
|
return inner();
|
|
}
|
|
|
|
with_eval();
|
|
outer_eval();
|