fix(hir): non-class expression-semantics remnant test262 parity#4922
Merged
Conversation
Five surgical fixes across language/expressions, +9 test262, 0 regressions (verified same-mode against the branch-parent baseline): - super.<prop> / super['<lit>'] data-property reads in a class method now resolve through the *declared* prototype object (stable heap identity), so a property added to a parent prototype after the class declaration is found. Previously the older overloaded CLASS_PROTOTYPE_OBJECTS table held a distinct synthetic prototype that never saw such writes -> undefined. (super/prop-dot-cls-val, prop-dot-cls-val-from-arrow) - super['<string-literal>'] in a class method routes to the ident-form super read/call (SuperPropertyGet / SuperMethodCall) instead of the this[index] approximation that read the CHILD instance and shadowed the parent value. (super/prop-expr-cls-val, prop-expr-cls-val-from-arrow; guarded against a computed super-method-call regression via SuperMethodCall routing) - x instanceof undefined now evaluates the RHS and throws TypeError (RHS is not an object) instead of folding to false. (instanceof/S11.8.6_A3) - is_iterable() recognizes generator objects (own next/return/throw closures) and built-in iterator objects, so call / new / super spread of a generator (f(...g()), new C(...g())) and new Map/Set(g()) drive the iterator protocol instead of falling through to the array-reinterpret garbage path. Errors thrown by the generator body now propagate. (call/spread-err-*-expr-throws, new/spread-err-*-expr-throws)
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
Five surgical fixes to non-class expression semantics in
language/expressions/*. +9 test262 cases, 0 regressions, verified same-mode (PERRY_NO_AUTO_OPTIMIZE=1) against a binary built at this branch's parent commit across all 11 target directories (super object yield generators async-generator call delete new property-accessors instanceof compound-assignment): pass 2001 → 2010, parity 88.6% → 89.0%.Also separately verified 0 regressions on iterable-heavy directories (
built-ins/Map,built-ins/Set,built-ins/Array/from,language/statements/for-of,built-ins/GeneratorPrototype) to bound the globalis_iterablechange.Root causes & fixes
1.
super.<prop>/super['<lit>']data-property reads miss dynamic parent-prototype writessuper.fromAin a class method routedjs_super_accessor_getthrough the older overloadedCLASS_PROTOTYPE_OBJECTStable, which can hold a distinct synthetic prototype from the stable declared-class prototype thatParent.prototype.foo = vactually writes to — so the read returnedundefined. Now prefers the declared prototype object (class_decl_prototype_object), falling back to the old table.→
super/prop-dot-cls-val,prop-dot-cls-val-from-arrow2. Computed
super['<string-literal>']read/call in a class methodThe computed super arm only handled object-literal methods (home stack); class methods fell back to
this[index], reading the child instance and shadowing the parent. String-literal computed keys now route to the ident-formSuperPropertyGet(reads) andSuperMethodCall(calls —super['m']()binds the currentthisas receiver).→
super/prop-expr-cls-val,prop-expr-cls-val-from-arrow(and guardsprop-expr-cls-ref-thisfrom regressing)3.
x instanceof undefinedfolded tofalseThe
undefinedidentifier on the RHS resolved to no class and codegen silently producedfalse. It now lowers to the undefined value and routes throughjs_instanceof_dynamic, which throwsTypeError(RHS not an object).→
instanceof/S11.8.6_A34. Generator spread into call /
newnot iteratedA Perry generator object is a plain object with own closure-valued
next/return/throwand no[Symbol.iterator]symbol property, sois_iterablemissed it andjs_array_like_to_array(call /new/ super spread) fell through to the array-reinterpret garbage path —f(...g())silently passed a malformed arg and generator-body throws never propagated.is_iterablenow recognizes generator objects (and built-in iterator objects), so spread drives the iterator protocol. Also fixesnew Map/Set(g()).→
call/spread-err-{mult,sngl}-err-expr-throws,new/spread-err-{mult,sngl}-err-expr-throwsFiles
crates/perry-hir/src/lower/expr_misc.rs— computed super string-literal readcrates/perry-hir/src/lower/expr_call/mod.rs— computed super string-literal method callcrates/perry-hir/src/lower/lower_expr.rs—instanceof undefineddynamic routingcrates/perry-runtime/src/object/property_key.rs— super read via declared prototypecrates/perry-runtime/src/collection_iter.rs—is_iterablerecognizes generators / built-in iteratorsOut of scope (deferred, high-risk / architectural)
super(...spread)— conflicts with Perry's positional inline-constructor model (runtime-dynamic spread length).yield*full abrupt-completion (return/throw) delegation — large state-machine change.new <non-ctor object/number>TypeError — blocked by NaN-box pointer/number ambiguity.