fix(hir): class test262 remnant (elements/dstr/private/async tail)#4888
Merged
Conversation
…is-binding, ctor return-override, arguments-in-defaults, static-field this
language/{statements,expressions}/class: 4839->5009 pass (90.1%->93.3%, +170, zero regressions).
- PerformEval early errors (new lower/eval_super_scan.rs): direct eval bodies
scanned per Contains semantics (arrows transparent, function/method bodies
opaque) for SuperCall / SuperProperty / arguments / new.target / private
names; violations throw SyntaxError at the eval call via new
js_throw_eval_syntax_error. Indirect (0,eval) is global code: any super or
new.target rejected, private names only if declared inside the source.
- Direct-eval IIFE wrapper is now an ARROW: eval'd code sees the caller's
this/arguments/super/new.target lexically (this.#x brand checks, this.prop
reads in methods/static-field inits).
- eval bodies with super.x that fail the script-level parse re-parse inside
an object-method wrapper when the call site provides super.
- Derived-ctor static no-super ReferenceError no longer fires when the body
has a value-bearing return (return-override) or a closure-captured super()
with no direct this use; bare return undefined still throws.
- arguments referenced from method/function parameter DEFAULTS now triggers
the synthetic-arguments param (and it is appended before defaults lower).
- this in static field initializers binds the class constructor (class-ref
seed in init_static_fields_late, mirroring compile_static_method).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Class-suite test262 tail (
language/statements/class+language/expressions/class): 4839 → 5009 pass (90.1% → 93.3%, +170, zero regressions). Broad cross-suite shard (--shard 0/12 built-ins language): 91.5% → 92.0% (+15 fixed, zero regressions). Native-region gate: pass (7/7 workloads).cargo test(hir/codegen/transform/runtime): all pass.Root causes fixed
PerformEval early errors for eval in class contexts (~120 tests; biggest bucket). New
crates/perry-hir/src/lower/eval_super_scan.rs: constant direct-eval bodies are scanned per spec Contains semantics (arrows transparent; function / class-member / object-method bodies opaque) forSuperCall,SuperProperty,arguments,new.target, and private-name references. Capabilities come from the lowering context:super()allowed only directly in a derived-class ctor (newcurrent_class_is_derived),super.xin any class member / object method,argumentsrejected in field initializers (newin_class_field_init, cleared inside nested plain functions), private names checked against the lexicalprivate_scopesstack. Violations compile to a runtime SyntaxError via newjs_throw_eval_syntax_error. Indirect(0, eval)evaluates as global code: any super ornew.targetrejected; private names valid only if declared inside the eval source.Direct-eval wrapper rebound
this(~30 tests). The constant-eval scope-IIFE template was a plainfunction, soeval(\"this.#x\")inside a method brand-checked againstundefinedandeval(\"this.prop\")readundefined. The wrapper is now an arrow, giving eval'd code the caller'sthis/arguments/super/new.targetlexically (spec: direct eval inherits all four).Allowed
super.xin eval bodies failed to parse (~24 tests). SWC rejects SuperProperty at script top level, sox = eval('() => super.x')threw a bogus SyntaxError. When the call site provides super, the body re-parses inside an object-method wrapper and the method body statements are spliced into the (now-arrow) IIFE.Derived-ctor static no-super throw too eager (~10 tests). The compile-time
ReferenceError: must call supernow stays silent when the ctor body has (a) a value-bearingreturn(return-override path; barereturn undefinedstill throws —Object/constructor-return-undefined-throws), or (b) a closure-capturedsuper()with no directthisuse (e.g.iter.f = () => super()invoked during for-of iterator close —derived-class-return-override-{for-of,finally-super,catch-finally}-arrow; the direct-thiscarve-out keepsprivatefieldset-evaluation-order-1throwing).argumentsin parameter defaults (8 tests).method(x = arguments[2], y) {}never synthesized the arguments object (the check only scanned the body), and the synth param was appended after defaults were lowered, soargumentsin a default resolved as an unknown global. Both fixed for class methods and free functions (class_members.rs,fn_decl.rs).thisin static field initializers (~4 tests).static g = this.f + '262'readundefined—init_static_fields_latenow seeds the same class-ref NaN-boxthisslot a static method binds.Validation
privatefieldset-evaluation-order-1,constructor-return-undefined-throws) were caught by the set-diff and fixed (direct-thiscarve-out +return undefinedexclusion) — final diff vs merge-base f32b486 is fixes-only, in-suite and cross-suite.compiler_output_regression.py suite --suite native-region-proof→failed_workloads: [].cargo fmt --allapplied; file-size gate OK (largest touched file 1706 lines).Knowingly deferred (tracked)
yield*return/throw forwarding (~80 remaining failures): the async-generator.throw()/.return()closures use deferred-resume and cannot re-enter the state machine; forwarding to the delegated iterator needs that contract rebuilt (pre-existing deferral from fix: yield* async-delegation test262 parity (next-capture + object-literal thenable await) #4783/fix(runtime): class subclass + async-method + definition test262 tail #4853).C.m.call(arbitraryObj)(~12): static-method dynamicthishardcodes the class ref (deferred in fix(hir): class field/element initializer test262 tail (v3, native-region-safe) #4847).extends nullsemantics, subclass-builtins exotics, per-field private install-order brand checks, named-class inner-binding immutability: each small, distinct, pre-existing buckets.No version bump / changelog edits per external-contributor flow.