Files
ladybird/Tests/LibJS/Bytecode/expected/destructuring-param-no-param-expressions.txt
Andreas Kling 18c40a1328 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.
2026-03-01 21:20:54 +01:00

21 lines
1.0 KiB
Plaintext

JS bytecode executable ""
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] GetGlobal dst:reg6, identifier:f
[ 18] NewObject dst:reg7
[ 28] InitObjectLiteralProperty object:reg7, property:captured, src:Int32(1), shape_cache_index:0, property_slot:0
[ 40] InitObjectLiteralProperty object:reg7, property:local, src:Int32(2), shape_cache_index:0, property_slot:1
[ 58] CacheObjectShape object:reg7
[ 68] Call dst:reg5, callee:reg6, this_value:Undefined, f, arguments:[reg7]
[ 90] End value:reg5
JS bytecode executable "f"
[ 0] 0: GetLexicalEnvironment dst:reg4
[ 8] CreateVariable identifier:captured, is_immutable:false, is_global:false, is_strict:false
[ 18] ThrowIfNullish src:arg0
[ 20] GetById dst:reg5, base:arg0, property:captured
[ 38] InitializeLexicalBinding identifier:captured, src:reg5
[ 50] GetById dst:reg5, base:arg0, property:local
[ 68] Mov dst:local~0, src:reg5
[ 78] NewFunction dst:reg5, shared_function_data_index:0
[ 90] Return value:reg5