Repository navigation
fix(wasm): super.f() in a static method reaches the parent's static methods on the web target (#15081) - #15088
Conversation
…ethods on the web target (PerryTS#15081) The static branch of __superGet looked only in classStaticTable, which holds static fields, so `super.f()` for a parent's named static method (classStaticMethodTable) or a computed static (a class value property) read undefined and threw. It now reads the parent through __classStaticGet, as a direct `Parent.f` access does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Summary
On
--target web,super.f()inside a static method threw(intermediate value).f is not a functionwhenfwas a parent's static method. The static branch of__superGetlooked only inclassStaticTable, which holds static fields. Named static methods (inclassStaticMethodTable, since #15015) and computed statics (on the class value) were never found. It now reads the parent through__classStaticGet, the lookup a directParent.fuses.Related issue
Fixes #15081
Type of change
Platforms
Tested on: macOS arm64 (Darwin 27.3), Node 26.12.1.
Changes
crates/perry-codegen-wasm/src/wasm_runtime.js: in__superGet, a static home returns__classStaticGet(parent, name, receiver, Function.prototype). A field, a named static method or a member of the class value is found asParent.xfinds it, and anything else falls back toFunction.prototypeas before. The function it returns takes itsthisfrom the call, sosuper.g()runsgwith the subclass asthis.crates/perry-codegen-wasm/src/emit/tests.rs:super_in_a_static_method_reaches_the_parents_static_methodscovers inherited static calls,super.f()from a subclass and from a grandchild, andsuper.g()readingthis.name. The expected string is Node 26.12.1's output.Test plan
Cause, verified on
main88b1e37:B.f()(the control, which goes through__classStaticGet) printsf, whilesuper.f()inB's static method throws fromclass_super_callbecause__superGetreturnedFunction.prototype.f.main88b1e37B.f()fffC.f()fffB.h() (super.f())fh(intermediate value).f is not a functionfhB.i() (super.g() keeps this)g:Bg:BC.h()fhfhThe whole repro in #15081 matches Node on this branch.
cargo test --release -p perry-codegen-wasm --lib super_in_a_static_method_reachespasses. With onlywasm_runtime.jsreverted (test kept), it fails with(intermediate value).f is not a function.cargo test --release -p perry-codegen-wasm --lib: 164 passed (163 onmain, plus the new test).main88b1e37 build,python3 scripts/parity.py run language typescript --mode web(3018 cases): pass→fail 0, fail→pass 0.test_gap_array_fill_3m_objects,test_gap_8691_scalar_replace_aggregate_callsandtest_sparse_array_readerschanged status only in the full run, while the machine's load average was about 20. Each was rerun twice in isolation and has the same status on both builds.cargo clippy --release -p perry-codegen-wasm --lib --tests: 290 warnings on both builds, none in a touched file.rustfmt: no Rust file changes outsidetests.rs, which is clean on the added lines.BASE_SHA=upstream/main SKIP_COMPILE_GATES=1 scripts/run_lint_gates.sh: the FAIL set (17 gates, environmental on this Mac or failing onmainitself) is identical to the one onmain88b1e37.main's first lint run also failed[Parity runner unit tests]; that gate passed 3 of 3 reruns onmain(a timing flake).This merges cleanly with each of our open PRs (#15026, #15027, #15028, #15029 (its fix commit), #15050, #15051, #15053, #15055, #15074, #15085, #15086).
Checklist
crates/addschangelog.d/<PR-number>-<slug>.mdfeat:/fix:/docs:/chore:prefix convention🤖 Generated with Claude Code
https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p
Summary by CodeRabbit
supernow works correctly and preserves the subclass asthis.