Registry Mirror
Skip to content

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Summary

Object.prototype.toString.call(new Date()) returned "[object Object]" instead of "[object Date]".

A Perry Date is a NaN-boxed pointer to a DateCell (#2089). js_object_to_string (crates/perry-runtime/src/object/mod.rs) discriminates heap pointers into Array/Error/Object by GC-header type but had no Date arm, so dates fell through to the generic Object tag.

Fix

Added a crate::date::is_date_value(value) check — the same brand predicate instanceof Date uses — immediately before the heap-pointer discrimination. Covers valid dates and Invalid Date (new Date(NaN)) alike.

Verification

  • Object.prototype.toString.call(new Date()) / new Date(0) / new Date(NaN) → "[object Date]", matching Node.
  • Regression sweep over util/types, util/inspect, date, globals (74 fixtures): all 6 remaining diffs are pre-existing and unrelated — util/inspect/error-cause-and-aggregate (stack-trace fidelity), util/inspect/boxed-and-symbols (boxed-String length enumeration, no Date), globals/builtin-name-length-descriptors (runtime: complete own name/length descriptors on builtins (follow-on to closed #3143) #3655), globals/storage-globals (web-storage; Node has none by default), and the two webassembly-* (deep WASM metadata). Date instance methods (toISOString/getTime/instanceof) and the ArrayBuffer/Array/Error/Object tags are unchanged.

Advances the Date conformance issue (#4031).

Object.prototype.toString.call(new Date()) returned "[object Object]"
instead of "[object Date]". A Perry Date is a NaN-boxed pointer to a
DateCell (#2089), and js_object_to_string (object/mod.rs) discriminated heap
pointers into Array/Error/Object by GC-header type but had no Date arm, so
dates fell through to the generic Object tag. Added a crate::date::is_date_value
check (the same brand predicate instanceof Date uses) before the heap
discrimination, covering valid dates and Invalid Date alike.

Advances the Date conformance issue (#4031).
@proggeramlug
proggeramlug merged commit ee6ea90 into main Jun 2, 2026
11 checks passed
@proggeramlug
proggeramlug deleted the cycle37-date-brand branch June 2, 2026 03:14
proggeramlug pushed a commit that referenced this pull request Jun 2, 2026
…4041)

The #1103 object.rs split trunk crossed the 2000-line gate on current
main; splitting the cache/root-scanner groups into siblings is tracked
under #1435. Matches the existing global_this/field_get_set/class_registry
allowlist precedent. Unblocks lint for all PRs.
proggeramlug added a commit that referenced this pull request Jun 2, 2026
#3961) (#4048)

* test(buffer): lock Uint8Array.prototype.buffer ArrayBuffer return type (#3961)

* ci(file-size): allowlist object/mod.rs trunk (2 LOC over after #4039-#4041)

The #1103 object.rs split trunk crossed the 2000-line gate on current
main; splitting the cache/root-scanner groups into siblings is tracked
under #1435. Matches the existing global_this/field_get_set/class_registry
allowlist precedent. Unblocks lint for all PRs.

---------

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
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