Repository navigation
Fix var initialization when it redeclares a parameter with an initializer - #5647
Basharkhan7776 wants to merge 1 commit into
Conversation
|
Hi @Basharkhan7776, great work on tracking this down! The fix cleanly addresses ECMAScript \FunctionDeclarationInstantiation\ step 28.h.iv. Reading from \scopes.parameter_scope()\ rather than the uninitialized \�arEnv\ correctly preserves the parameter binding value, and removing the erroneous \emit_store_undefined\ prevents clobbering that copied value before \DefInitVar. Tested locally against \main\ via \cargo test -p boa_engine function\ and all tests pass cleanly. The added test cases in \core/engine/src/tests/function.rs\ cover arrow functions, default parameter expressions, and closure capture thoroughly. Looks solid! |
|
Thanks for the review. Glad the parameter-environment read and the removed |
Test262 conformance changes
Fixed tests (1):Tested main commit: |
HalidOdat
left a comment
There was a problem hiding this comment.
Nice catch! Thanks for the contribution! 🚀
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5647 +/- ##
===========================================
+ Coverage 47.24% 63.17% +15.93%
===========================================
Files 476 538 +62
Lines 46892 60608 +13716
===========================================
+ Hits 22154 38292 +16138
+ Misses 24738 22316 -2422 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #5634.
When a function has parameter expressions,
FunctionDeclarationInstantiationstep 28 gives the body'svarnames a separatevarEnv. Avarwhose name is also a parameter must be initialized from the parameter environment (env.GetBindingValue), not fromvarEnv.The bytecompiler read
varEnvinstead. That binding has no register yet, so compilation emittedThrowNewReferenceError("access of uninitialized binding")before the body ran. A lateremit_store_undefinedalso discarded the copied value, so a barevar bwould have becomeundefinedinstead of the parameter's value.GetBindingValuenow usesscopes.parameter_scope(), andDefInitVarstores that value. Parameter-list closures still close over the parameter environment.