Skip to content

fix(wasm): super.f() in a static method reaches the parent's static methods on the web target (#15081) - #15088

Merged
TheHypnoo merged 2 commits into
PerryTS:mainfrom
raliclo:fix/wasm-static-super-method
Nov 20, 2026
Merged

TheHypnoo merged 2 commits into
PerryTS:mainfrom
raliclo:fix/wasm-static-super-method

Conversation

@raliclo

@raliclo raliclo commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On --target web, super.f() inside a static method threw (intermediate value).f is not a function when f was a parent's static method. The static branch of __superGet looked only in classStaticTable, which holds static fields. Named static methods (in classStaticMethodTable, since #15015) and computed statics (on the class value) were never found. It now reads the parent through __classStaticGet, the lookup a direct Parent.f uses.

Related issue

Fixes #15081

Type of change

  • Bug fix

Platforms

  • WebAssembly / web

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 as Parent.x finds it, and anything else falls back to Function.prototype as before. The function it returns takes its this from the call, so super.g() runs g with the subclass as this.
  • crates/perry-codegen-wasm/src/emit/tests.rs: super_in_a_static_method_reaches_the_parents_static_methods covers inherited static calls, super.f() from a subclass and from a grandchild, and super.g() reading this.name. The expected string is Node 26.12.1's output.

Test plan

Cause, verified on main 88b1e37: B.f() (the control, which goes through __classStaticGet) prints f, while super.f() in B's static method throws from class_super_call because __superGet returned Function.prototype.f.

cargo build-perry --release && scripts/gc_call_effects/sidecars.sh target/release
perry compile pe.ts --target web -o pe.html && node scripts/parity_web_host.cjs pe.html
case Node 26.12.1 main 88b1e37 this branch
B.f() f f f
C.f() f f f
B.h() (super.f()) fh throws (intermediate value).f is not a function fh
B.i() (super.g() keeps this) g:B (not reached) g:B
C.h() fh (not reached) fh

The whole repro in #15081 matches Node on this branch.

  • Fail before, pass after: cargo test --release -p perry-codegen-wasm --lib super_in_a_static_method_reaches passes. With only wasm_runtime.js reverted (test kept), it fails with (intermediate value).f is not a function.
  • cargo test --release -p perry-codegen-wasm --lib: 164 passed (163 on main, plus the new test).
  • Web parity A/B against a pristine main 88b1e37 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_calls and test_sparse_array_readers changed 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 outside tests.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 on main itself) is identical to the one on main 88b1e37. main's first lint run also failed [Parity runner unit tests]; that gate passed 3 of 3 reruns on main (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).

  • Added or updated a test in the layer that owns it

Checklist

  • I have NOT bumped the workspace version or edited CHANGELOG.md
  • A change under crates/ adds changelog.d/<PR-number>-<slug>.md
  • My commits follow the feat: / fix: / docs: / chore: prefix convention
  • I've read CONTRIBUTING.md and agree to the Code of Conduct

🤖 Generated with Claude Code

https://claude.ai/code/session_01CUQanVsnitcrmYLAWWPc3p

Summary by CodeRabbit

  • Bug Fixes
    • For web builds, calling a parent’s static method with super now works correctly and preserves the subclass as this.

ralic and others added 2 commits November 20, 2026 07:17
…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
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

For --target web, static super lookup now uses the shared class-static resolution path. A new runtime test checks inherited static methods, super calls, and preservation of the subclass as this.

Changes: WASM static super lookup

Layer / File(s) Summary
Static super lookup and validation
crates/perry-codegen-wasm/src/wasm_runtime.js, crates/perry-codegen-wasm/src/emit/tests.rs, changelog.d/15088-wasm-static-super-method.md
__superGet now delegates static lookup to __classStaticGet. The runtime test checks inherited static methods and super calls, including the subclass as this. The changelog records the --target web behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: type:bug, platform:wasm, area:compiler

Suggested reviewers: thehypnoo

Merge Risk: Minimal · up to 5b366

On --target web, super.f() in a static method now reaches the parent's static members and keeps the subclass as this. A regression test covers the issue's examples, including a grandchild call. The visible CI failure is a thread-local policy check on an unrelated file, so no merge-blocking risk remains from this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fix so super.f() in a static method reaches the parent's static methods on the web target. It matches the changeset, which edits __superGet in wasm_runtime.js and ad…
Description check Passed The description follows the template. It has a Summary, a Related issue (Fixes #15081), a Type of change (Bug fix checked), Platforms (WebAssembly / web checked, with the test machine named), a Change…
Linked Issues check Passed Issue #15081 requires super.x in a static method to find parent static members on --target web, as Parent.x does. The PR summary states that the static branch of __superGet in `wasm_runtime.js…
Out of Scope Changes check Passed The PR changes three files. (1) crates/perry-codegen-wasm/src/wasm_runtime.js: the static branch of __superGet now delegates to __classStaticGet. This is the fix for #15081. (2) `crates/perry-co…
Full details: Title check

Explanation

The title names the main change: a fix so super.f() in a static method reaches the parent's static methods on the web target. It matches the changeset, which edits __superGet in wasm_runtime.js and adds a web-target test. The title is 102 characters, slightly above a short ideal, but it stays specific and readable.

Full details: Description check

Explanation

The description follows the template. It has a Summary, a Related issue (Fixes #15081), a Type of change (Bug fix checked), Platforms (WebAssembly / web checked, with the test machine named), a Changes list naming the touched files, a Test plan with commands, results and a before/after table, and a checked Checklist. It does not fill the template's Screenshots section, which is optional. The template's Changelog checkbox is ticked, but the description does not name the changelog.d file it adds, so that item is only partly evidenced. Minor gaps do not make the description incomplete.

Full details: Linked Issues check

Explanation

Issue #15081 requires super.x in a static method to find parent static members on --target web, as Parent.x does. The PR summary states that the static branch of __superGet in wasm_runtime.js now calls __classStaticGet(parent, name, receiver, Function.prototype). This matches the fix proposed in #15081. __classStaticGet checks static fields, classStaticMethodTable, and class-value properties. The receiver argument keeps this as the subclass, so super.g() yields g:B. The added test super_in_a_static_method_reaches_the_parents_static_methods covers the issue cases: super.f() from B, super.f() from a grandchild, and super.g() reading this.name. The PR reports that this test fails when only wasm_runtime.js is reverted. Limitation: the diff read for wasm_runtime.js failed because the changed blobs are missing from the checkout. The __superGet hunk was therefore not read directly. This verdict rests on the PR summary, the author's test results, and the test's coverage of the issue cases.

Full details: Out of Scope Changes check

Explanation

The PR changes three files. (1) crates/perry-codegen-wasm/src/wasm_runtime.js: the static branch of __superGet now delegates to __classStaticGet. This is the fix for #15081. (2) crates/perry-codegen-wasm/src/emit/tests.rs: adds one test that covers the #15081 cases. (3) changelog.d/15088-wasm-static-super-method.md: a changelog entry for the fix. The changelog entry is required by the PR checklist for changes under crates/. All changes connect to #15081. No unrelated change appears in the summary. The wasm_runtime.js hunk was not read directly, so this verdict also depends on the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3eb300d8-b60e-4d04-9408-038b0683fbec
Commits

Reviewing files that changed from the base of the PR and between 88b1e37 and 5b3666a.

Files selected for processing: 3

  • changelog.d/15088-wasm-static-super-method.md
  • crates/perry-codegen-wasm/src/emit/tests.rs
  • crates/perry-codegen-wasm/src/wasm_runtime.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:compiler parser, HIR, transform, codegen, wpfacts platform:wasm Specific to wasm type:bug Confirmed defect or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasm/web: super.f() in a static method throws when f is a parent's static method

3 participants