test262: Number conformance fixes (wave 15) - #77
Merged
Conversation
Number.prototype is itself a Number object whose [[NumberData]] is +0
(ES2023 21.1.3), so Number.prototype.toString() and .toString(radix) for
any radix 2-36 must return "0" per 21.1.3.6. Previously the receiver was
the opaque builtin_prototype("Number") marker, whose ToNumber is NaN, so
toString fell through to the generic object form and produced
"[object Object]".
Route Number.prototype.toString(...) through num_to_string_radix with a
literal 0 receiver. Clears the whole test262 Number/prototype/toString
S15.7.4.2_A1/_A2 family (37 files), which each open with a
Number.prototype.toString assertion before the boxed-wrapper cases.
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.
Renders
Number.prototype.toString(radix)as "0".Spec
Number.prototypeis itself a Number object whose [[NumberData]] is +0 (ES2023 21.1.3). Per 21.1.3.6,Number.prototype.toString()and.toString(radix)for any radix 2-36 (or absent/undefined/10) therefore render as "0" (0 is the same digit in every base).Bug
The receiver was the opaque
builtin_prototype("Number")marker, whose ToNumber is NaN, so toString fell through to the generic object form and produced"[object Object]".Fix
Route
Number.prototype.toString(...)through the existingnum_to_string_radixruntime op with a literal 0 receiver (newlower_number_proto_tostringhelper in lower.gleam). No FFI/runtime change —num_to_string_radixalready existed.Result
test262 built-ins/Number: pass 55 -> 92 (RAN 100%), fail_assert 37 -> 0. Clears the whole
Number/prototype/toStringS15.7.4.2_A1/_A2 family (37 files), which each open with aNumber.prototype.toStringassertion before boxed-wrapper cases that already rendered correctly. Remaining 12 are Test262Error-class / Object.defineProperty / closure-capture-of-NaN tarpits, out of scope.Spec-driven tests appended at EOF of js_compiler_test.gleam under
// ==== Number (wave 15) ====.