Files
scriptc/tests
Chris Tate 6bbabd5fc9 Convert dynamic values into nested unions in one pass
Converting a dynamic value into a union (`JSON.parse(text) as T`, a cast
from `any`) tries the arms in order and builds the first arm whose literal
discriminator and whole structure match. The builder of that arm converts
its members, and a member typed as another union matched its arm's
structure again. Every value was matched once per union around it, so
converting a tree of depth d cost about d times as much as a flat one.

The arm a union matched now builds as a trusted conversion
(scr_dyn_trust_enter). Inside it, a nested union picks an arm without
matching the arm's structure, which the enclosing match already checked,
when the value's arm is known: a plain object's arm by its literal, when
the arms' literals are disjoint and no arm without a literal takes plain
objects, or the only arm that takes plain objects (a record) or arrays (an
array), as in an optional or nullable member. Other unions, and values that
are not plain objects or arrays, match as before. Getters and proxy traps
run outside the trusted conversion. Failed conversions throw the same
TypeError with the same path.
2026-10-22 20:15:02 -05:00
..
…
2026-10-20 17:56:44 -05:00