Files
ladybird/Tests/LibJS/Bytecode/input/assign-to-let-variable-tdz.js
Andreas Kling ac35ef465b LibJS: Emit ThrowIfTDZ before simple assignment to let variables
The Rust bytecode codegen was missing a TDZ check before assigning to
local let/const variables in simple assignment expressions (a = expr).
The C++ pipeline correctly emits ThrowIfTDZ before the store to ensure
temporal dead zone semantics are enforced.

Add an emit_tdz_check_if_needed helper matching the C++ equivalent,
and call it in the simple assignment path.
2026-03-04 18:53:12 +01:00

13 lines
282 B
JavaScript

// Test that simple assignment to a let variable emits ThrowIfTDZ
// before the store, ensuring TDZ semantics are enforced.
function g(x) { return x; }
function f(n) {
let { location: a } = n;
"string" == typeof a && (a = g(a));
return a;
}
f({ location: "hello" });