fix(runtime): small built-ins tails (Date setters/parse, BigInt ++/--)#4901
Merged
Conversation
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
Mops several small high-% built-in tails (Date + BigInt) from the test262 sweep over
built-ins/{Number,Boolean,Symbol,Error,Map,Set,Weak*,Reflect,BigInt,Math,Date,ArrayBuffer,URI,parse*,global}.Parity 93.4% → 95.0% over 2314 judged tests: +38 fixed, 0 regressed (Date 37, BigInt 1), verified by diffing failure sets against a from-scratch build of the merge base (
aee4e82c5).Root causes & fixes
Date
set*coercion order (date.rs::js_date_apply_setter) —thisTimeValuemust be read before coercing any argument, then all present arguments coerced left-to-right before the NaN-time short-circuit. The code did the opposite (read-AFTER the leading arg, short-circuited before coercing the rest). node v26 confirms read-before / coerce-all. Fixesset{Date,Hours,Minutes,Seconds,Milliseconds,Month,FullYear,UTC*}/{date-value-read-before-tonumber-*,arg-coercion-order}(~22).Date expanded-year ISO parse (
date.rs::parse_iso8601) — accept the±YYYYYYextended-year form (mandatory sign, 6 digits;-000000rejected) in addition to 4-digitYYYY.new Date('-000001-07-01T00:00Z')no longer yields Invalid Date, fixing the{toString,toDateString,toUTCString}/negative-yearset.Date
toISOStringexpanded-year (iso_year) — years outside0..=9999serialize as±YYYYYY(new Date(8.64e15).toISOString()→+275760-09-13T00:00:00.000Z).Date.UTC/ constructor year rebasing (rebase_two_digit_year) — applyToInteger(truncate-toward-zero) before the0..=99two-digit-year test, soDate.UTC(-0.999999, 0)rebases to 1900, not literal year 0.Date.parseTimeClip — a parsed instant outside ±8.64e15 ms is now Invalid (Date.parse("-271821-04-19T23:59:59.999Z")→ NaN).BigInt-preserving
++/--(dynamic_arith.rs+ codegenliterals_vars.rs) — the update slow path coerced the operand withjs_number_coerce+fadd 1.0, collapsing a BigInt to a Number (let i = 10n; i++produced the Number11, so a lateri + 87nthrew a mixed-typeTypeError). Newjs_to_numeric(ToNumeric: BigInt passthrough, else ToNumber) +js_numeric_step(steps by1n/1.0of the operand's own type). Non-BigInt behavior is byte-identical; integer-local fast path (fadd) unchanged. FixesBigInt/prototype/toString/a-z.Files
crates/perry-runtime/src/date.rscrates/perry-runtime/src/value/dynamic_arith.rscrates/perry-codegen/src/expr/literals_vars.rscrates/perry-codegen/src/runtime_decls/strings.rsValidation
--jobs 40.aee4e82c5→ 38 fixed, 0 regressed.Cargo.toml/CLAUDE.md/CHANGELOG.mdedits (maintainer folds version/changelog at merge).