ReviewOS

zig-utils/zig-js

Date: ignore coercion of arguments beyond seven components

#1063
Closed chris opened this 9 days ago ·
9 days ago

Parent: #475 Related: #1062

The multi-component Date constructor coerces every supplied argument, including arguments after the seven defined components. Those extra values must be evaluated by the call expression but not converted by Date.

Executed probe: an eighth argument with a throwing valueOf produces true,0 in Node (construction succeeds, no coercion). The saved before binary produces false,1 in both tree and required-bytecode modes.

Acceptance:

  • Coerce only year/month/day/hour/minute/second/millisecond, once each in order; ignore further values without suppressing argument-expression evaluation.
  • Use bounded local component storage instead of an arena allocation proportional to the argument count.
  • Pin extra throwing/NaN/Symbol/BigInt values, observable expression evaluation, NaN and abrupt ordering, and inherited Date constructors against Node.
  • Normal/unsuppressed TSan, GC-enabled required bytecode, and before/after full Date corpus checks pass.
9 days ago

Fixed in 11bc9b3.

Date now converts only the seven defined components and keeps them in a bounded local buffer. Additional argument expressions still execute at the call site; their resulting objects, NaN, Symbols, and BigInts undergo no Date conversion.

The throwing eighth-argument probe changes from false,1 to Node's true,0 in both tree and required-bytecode modes. Five Node-confirmed matrices pin evaluation/coercion order, NaN and abrupt behavior, derived construction, and ignored extra values. The GC-enabled engine fixture performs collection during each component conversion in isolated/shared required-bytecode contexts.

Focused tests pass 3/3 normally and 3/3 under unsuppressed TSan. The full Date corpus remains 594 pass / 0 fail before and after, with byte-identical output and zero flips. The 594-case tree/VM witness has zero divergences; inventory passes.

Sign in to comment on this issue.