mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
Fix two bugs in the Rust bytecode codegen:
1. has_parameter_expressions incorrectly treated any destructuring
parameter as a "parameter expression", when it should only do so
for patterns that contain expressions (defaults or computed keys).
This caused an unnecessary CreateLexicalEnvironment for simple
destructuring like `function f({a, b}) {}`. The same bug existed
in both codegen.rs and lib.rs (SFD metadata computation).
2. emit_set_variable used is_local_lexically_declared(index) for
argument locals, but that function indexes into the local_variables
array using the argument's index, checking the wrong variable.
This caused spurious ThrowIfTDZ instructions when assigning to
function arguments that happened to share an index with an
uninitialized let/const variable.
12 lines
223 B
JavaScript
12 lines
223 B
JavaScript
// Test that assigning to a function argument does NOT emit a ThrowIfTDZ
|
|
// instruction. Arguments are always initialized, so TDZ checks are
|
|
// unnecessary.
|
|
|
|
function f(x) {
|
|
let y = 1;
|
|
x = y;
|
|
return x;
|
|
}
|
|
|
|
f(0);
|