Skip to content

[TS] Preserve native Date constructor identity - #537

Merged
CaelmBleidd merged 2 commits into
mainfrom
caelmbleidd/fix-date-constructor-identity
Oct 16, 2026
Merged

CaelmBleidd merged 2 commits into
mainfrom
caelmbleidd/fix-date-constructor-identity

Conversation

@CaelmBleidd

Copy link
Copy Markdown
Member

Native Date values had no stable constructor identity when the SDK was absent from the input scene. date-fns-style date instanceof Date therefore stopped on an unknown RHS, while aliases and new date.constructor(...) could not preserve native construction semantics.

Add nominal Date identity from JacoDB's bundled standard library and retain the existing unknown-call boundary for Date APIs. Direct and aliased native construction, instanceof, and the inherited Date.prototype.constructor value now share one identity. Own constructor overrides take precedence; deleting the override restores the inherited constructor. Source bindings named Date remain ordinary application values, and plain objects/primitive/nullish values do not become native Dates.

A native Date constructor completed through FRESH retains its allocated receiver and gets an unconstrained internal timestamp. This preserves the known [[Construct]] object identity in EMPTY and FROZEN while keeping missing timestamp semantics explicitly approximate/FRESH. Unknown arbitrary functions retain the existing unsupported constructor behavior. Mutable Date.prototype access remains explicitly unsupported.

Validation:

  • 105 focused tests pass across Date identity, existing Date models, runtime new/instanceof, unknown-call dispatch, and stopped-prefix handling; zero failures/skips.
  • Four original parameterized regression cases fail on the unchanged main baseline in both EMPTY_FRESH and FROZEN_FRESH.
  • Source tests and Node replay check direct/aliased/zero-argument construction, argument side effects, native and shadowed identity, constructor inheritance/own overrides/deletion, and cloning through the constructor property. Separate checks retain the prototype-mutation boundary.
  • All existing Date model value and observation/provenance checks pass, including frontend callee preservation.
  • :usvm-ts:detektMain, :usvm-ts:detektTest, and git diff --check pass.

No JacoDB change or Date model arithmetic rewrite is included. Full suites and the 200-class diagnostic campaign remain part of the combined integration validation. Constructor dispatch PR #529 is independently reviewable; its dynamic-new follow-up preserves the same alias paths.

@CaelmBleidd
CaelmBleidd merged commit 7d254a6 into main Oct 16, 2026
6 checks passed
@CaelmBleidd
CaelmBleidd deleted the caelmbleidd/fix-date-constructor-identity branch October 16, 2026 13:03
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