Skip to content

fix(runtime): small built-ins tails (Date setters/parse, BigInt ++/--)#4901

Merged
proggeramlug merged 3 commits into
mainfrom
builtins-misc-box-parity
Jun 10, 2026
Merged

fix(runtime): small built-ins tails (Date setters/parse, BigInt ++/--)#4901
proggeramlug merged 3 commits into
mainfrom
builtins-misc-box-parity

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

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

  1. Date set* coercion order (date.rs::js_date_apply_setter) — thisTimeValue must 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. Fixes set{Date,Hours,Minutes,Seconds,Milliseconds,Month,FullYear,UTC*}/{date-value-read-before-tonumber-*,arg-coercion-order} (~22).

  2. Date expanded-year ISO parse (date.rs::parse_iso8601) — accept the ±YYYYYY extended-year form (mandatory sign, 6 digits; -000000 rejected) in addition to 4-digit YYYY. new Date('-000001-07-01T00:00Z') no longer yields Invalid Date, fixing the {toString,toDateString,toUTCString}/negative-year set.

  3. Date toISOString expanded-year (iso_year) — years outside 0..=9999 serialize as ±YYYYYY (new Date(8.64e15).toISOString()+275760-09-13T00:00:00.000Z).

  4. Date.UTC / constructor year rebasing (rebase_two_digit_year) — apply ToInteger (truncate-toward-zero) before the 0..=99 two-digit-year test, so Date.UTC(-0.999999, 0) rebases to 1900, not literal year 0.

  5. Date.parse TimeClip — a parsed instant outside ±8.64e15 ms is now Invalid (Date.parse("-271821-04-19T23:59:59.999Z") → NaN).

  6. BigInt-preserving ++/-- (dynamic_arith.rs + codegen literals_vars.rs) — the update slow path coerced the operand with js_number_coerce + fadd 1.0, collapsing a BigInt to a Number (let i = 10n; i++ produced the Number 11, so a later i + 87n threw a mixed-type TypeError). New js_to_numeric (ToNumeric: BigInt passthrough, else ToNumber) + js_numeric_step (steps by 1n/1.0 of the operand's own type). Non-BigInt behavior is byte-identical; integer-local fast path (fadd) unchanged. Fixes BigInt/prototype/toString/a-z.

Files

  • crates/perry-runtime/src/date.rs
  • crates/perry-runtime/src/value/dynamic_arith.rs
  • crates/perry-codegen/src/expr/literals_vars.rs
  • crates/perry-codegen/src/runtime_decls/strings.rs

Validation

  • Built + tested on a 48-core box against test262 (node v26 oracle), --jobs 40.
  • Zero-regression proof: failure-set diff vs a clean build of merge base aee4e82c5 → 38 fixed, 0 regressed.
  • No Cargo.toml/CLAUDE.md/CHANGELOG.md edits (maintainer folds version/changelog at merge).

@proggeramlug proggeramlug merged commit be15dd2 into main Jun 10, 2026
12 of 13 checks passed
@proggeramlug proggeramlug deleted the builtins-misc-box-parity branch June 10, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant