Test262: fromCodePoint surrogates (#108), call arg-order (#106), Object.create proto + isPrototypeOf (#104)#714
Merged
Conversation
…ct.create proto+isPrototypeOf (#104) #108 — String.fromCodePoint rejected lone surrogates (0xD800-0xDFFF) because char.ConvertFromUtf32 throws on them. Implement ECMA-262 §11.1.3 UTF16EncodeCodePoint in both modes (cp<=0xFFFF -> single code unit incl. lone surrogates; else surrogate pair). Also enforce the §22.1.2.2 integral check in the interpreter. Clears all RuntimeErrors in RegExp/CharacterClassEscapes; the remaining \w/\s failures are the .NET ECMAScript-shorthand divergence (#693). #106 — Compiled `o.bar.gar(foo())` evaluated arguments before the member-access callee threw. Per §13.3.2.1/§13.3.6.1, evaluating `recv.method` runs RequireObjectCoercible(recv) before ArgumentListEvaluation, so an undefined receiver must throw TypeError before the args' side effects. Add EmitThrowIfReceiverUndefined on the method-call path (EmitMethodCall + EmitGetPropertyAndInvoke). Guards on $Undefined only — compiled sloppy `this` is null and must stay coercible (avoids regressing this.bar(foo()), 11.2.3-3_8). #104 — Interpreter Object.create lagged compiled. Two fixes: (1) validate the prototype argument (§20.1.2.2 step 1) and throw a real SharpTSTypeError for a non-Object/non-null proto, matching compiled; (2) Object.prototype.isPrototypeOf was a stub returning false — implement the §20.1.3.4 chain walk. The titled built-in property-bag accessor iteration remains (needs accessor storage on Math/JSON/Date/Error/wrappers) — scoped out and documented on #104. #105 already satisfied both modes; added a regression suite to lock .length + receiver guards (Test262 isn't part of `dotnet test`). Baselines updated only for the folders these changes deterministically affect (Object/create, RegExp/CharacterClassEscapes, expressions/call 11.2.3-3); the rest of the suite had drifted/was flaky under parallel regen and is left for a maintainer full regen. Full unit suite: 12,740 pass. Filed #693 (\w/\s ECMAScript shorthand class semantics) and #694 (interpreter built-ins throwing string-typed TypeError instead of an Error instance).
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.
Addresses Test262 issues #104, #105, #106, #108, #112. A recurring theme: most were substantially stale — intervening main work had already resolved much of each — so every issue was re-measured against the live baseline before acting.
What changed
#108 —
String.fromCodePointlone surrogates (fixed, both modes)char.ConvertFromUtf32throws on lone surrogates (0xD800–0xDFFF), but they are valid code points forfromCodePoint. Implemented ECMA-262 §11.1.3 UTF16EncodeCodePoint (cp <= 0xFFFF→ single code unit incl. lone surrogates; else surrogate pair) in both the interpreter (StringBuiltIns.AppendCodePoint) and compiled (RuntimeEmitter.EmitStringFromCodePoint), and added the §22.1.2.2 integral check to the interpreter. Clears every RuntimeError inRegExp/CharacterClassEscapes/.#106 — argument evaluation order vs. callability (fixed, compiled)
Per §13.3.2.1/§13.3.6.1, evaluating a member-access callee
recv.methodrunsRequireObjectCoercible(recv)before ArgumentListEvaluation — soo.bar.gar(foo())witho.barundefined must throwTypeErrorbeforefoo()runs. Compiled mode deferred the throw past the args. AddedEmitThrowIfReceiverUndefinedon the method-call path. It guards on$Undefinedonly (not barenull): compiled sloppy-modethisis represented asnulland must stay coercible, sothis.bar(foo())still evaluates its args (this caught a11.2.3-3_8regression during development).#104 —
Object.create(interpreter parity, partial)The interpreter lagged compiled badly. Two fixes: (1) validate the prototype argument (§20.1.2.2 step 1) and throw a real
SharpTSTypeErrorfor a non-Object/non-null proto — crucially viaThrowException(new SharpTSTypeError(...)), notnew Exception("TypeError: …"), soassert.throws(TypeError, …)/instanceofsee an Error instance (see #694); (2)Object.prototype.isPrototypeOfwas a stub returningfalse— implemented the §20.1.3.4 chain walk. The titled core (iterating built-in property bags with accessors) needs accessor storage on Math/JSON/Date/Error/wrappers — a larger multi-type feature, scoped out and documented on #104.#105 — built-in method
.length+ receiver guards (already satisfied)Confirmed both modes already meet the spec (landed with #101). Added a regression suite (
BuiltInMethodLengthAndReceiverTests) since the Test262 project isn't part ofdotnet test.#112 — RegExp
Symbol.*edge cases (not fixed, triaged)All 7 require infrastructure beyond focused scope: surrogate-aware unicode matching (overlaps #693), sloppy-
this=globalThis binding, cross-realm$262.createRealm(no realm model — out of scope), and built-in-constructor property assignment (Array.print = printblockscoerce-global). Full per-cluster root-cause analysis posted to #112.New issues filed
\w/\sECMAScript shorthand classes diverge from JS (.NET\wmatches U+0130,\smisses Unicode whitespace). This is why 4CharacterClassEscapestests still fail.new Exception("TypeError: …")which is caught as a plain string, not an Error instance (compiled mode is correct).Tests / verification
StringMethodTests,NonCallableInvocationTests,ObjectCreateTests,ObjectPrototypeTests,BuiltInMethodLengthAndReceiverTests).Reviewer notes — Test262 baselines
The committed baseline changes are deliberately scoped to the folders these fixes deterministically affect (
Object/create,RegExp/CharacterClassEscapes, theexpressions/call/11.2.3-3family): interpreted +45 lines, compiled +13 lines, all sensible transitions, noPass → non-Passregressions. A full regen surfaced large pre-existing drift (recent main work the stale baseline never captured) plus parallel-execution flakiness in unrelated paths; including that would muddy the diff and commit flaky values, so it's left for a maintainer full regen. No CI workflow runs the Test262 conformance suite, so this doesn't gate the PR.