mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibJS/Rust: Fix has_parameter_expressions and TDZ checks for arguments
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.
This commit is contained in:
committed by
Andreas Kling
parent
766567a9d5
commit
18c40a1328
Notes:
github-actions[bot]
2026-03-01 20:24:33 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/18c40a1328e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8239
@@ -0,0 +1,10 @@
|
||||
// Test that simple destructuring parameters (without default values or
|
||||
// nested expressions) do NOT create a separate parameter environment.
|
||||
// The non-local binding should use CreateVariable directly in the
|
||||
// function environment, not in a new CreateLexicalEnvironment.
|
||||
|
||||
function f({ captured, local }) {
|
||||
return () => captured;
|
||||
}
|
||||
|
||||
f({ captured: 1, local: 2 });
|
||||
Reference in New Issue
Block a user