Repository navigation
Conversation
`S.isEqualOutput(S.nullable(S.union([A, B])))` threw on `(null, a)`: the discriminant pass swaps each object member's type test for a property read, `a.TAG==="A"`, and that read is a TypeError on the two values the union's null arm was waiting further down the chain to catch. The same read on `b` threw for `(a, null)`. The nullish split already existed, but only for one member of substance. It now applies to any count: null and undefined are tested first on both values, and the rest of the union dispatches only once each value is known to be neither. That is sound for the reason it already was, since no other narrow admits either value, and it makes every narrow's domain the values a property read can't throw on. Known bug `eq-tagged-union-absent` is gone from scripts/knownBugs.ts and `eq-tagged-union-nullable` now carries the `null` example the harness could not compare before. Three specs with a trailing null member now test it first, which also drops the last arm's redundant narrow on `a`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Spec performance3 slower, 1 faster of 3733 timed targets · Slower
Faster
+% slower than baseline, -% faster · noise floor create 3.3% · create+compile 3.0% · run 3.0% · scenario 3.0% |
#461 fixed `eq-tagged-union-absent` on main by optional-chaining every discriminant read (`a?.TAG`, `b?.TAG`) once a union has a nullish member. With null and undefined tested first on both values, no discriminant read ever sees either, so the chaining is dropped: one mechanism, not two, and `eq-tagged-union-nullable` compiles to the split form. `isEqual*` and `compare*` are 13 gzip bytes smaller than main's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
?.
Spec performance1 slower, 1 faster of 3848 timed targets · Slower
Faster
+% slower than baseline, -% faster · noise floor create 3.2% · create+compile 4.2% · run 3.0% · scenario 3.0% |
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
A tagged union beside `S.env` still threw in `isEqual`: env is tagged
string but admits undefined, so it stayed in the dispatch and the
discriminant read `a.TAG` on undefined. It now adds undefined to the
nullish split and stays in the dispatch for its strings:
S.isEqualOutput(S.union([A, B, S.env]))(undefined, { TAG: "A", _0: "x" })
// before: TypeError, after: false
`compare` of a tuple with an env slot answered 0 for
`[undefined, "a"]` vs `[undefined, "b"]`: env's leaf held a 0 in the
middle of its ternary, and chaining the next slot into the trailing
`:0` left that inner 0 ending the whole compare. The leaf is now
`(b===void 0)-(a===void 0)||(a<b?-1:a>b?1:0)`, which chains with `||`.
Neither was reachable by a fuzzer: the sampler had no value for env,
and a nested union has two members, so a tagged pair beside a third
never drew. Env now samples "x" or undefined, and the grammar draws
two tagged objects beside a leaf; without the fix, fuzz:schema reports
both bugs. Specs: eq-tagged-union-env, compare-tuple-env.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 3881 timed targets · Slower
+% slower than baseline, -% faster · noise floor create 7.8% · create+compile 3.0% · run 7.5% · scenario 12.9% |
…llish Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performanceNo significant changes of 3881 timed targets · +% slower than baseline, -% faster · noise floor create 3.0% · create+compile 3.2% · run 13.6% · scenario 6.0% |
No conflicts; every golden regenerates unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performanceNo significant changes of 3954 timed targets · +% slower than baseline, -% faster · noise floor create 5.5% · create+compile 4.6% · run 3.4% · async 3.1% · scenario 37.6% |
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 4233 timed targets · Slower
+% slower than baseline, -% faster · noise floor create 6.7% · create+compile 3.0% · run 3.0% · async 3.0% · scenario 3.8% |
Generated files (bundleSize.yaml, benchmark goldens) regenerated rather than hand-merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 4255 timed targets · Slower
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 4.9% · run 3.0% · async 7.1% · scenario 4.3% |
Version bump only; no conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 4255 timed targets · Slower
+% slower than baseline, -% faster · noise floor create 10.9% · create+compile 3.0% · run 6.2% · async 3.2% · scenario 14.9% |
Generated goldens take main's side and are regenerated after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Spec performance2 faster of 6475 timed targets · Faster
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 4.6% · run 3.8% · async 3.0% · scenario 22.1% |
Known bug
eq-tagged-union-absent. #461 has since fixed it onmainby optional-chaining every discriminant read. This PR replaces that with a structural fix, and it's now merged withmain.Cause
When object members share a type narrow, the discriminant pass swaps each one's type test for a property read,
a.TAG==="A". That read throws on null and undefined, which the union's nullish arm was waiting further down the chain to catch.Fix
The comparator already split nullish literals off
S.optional(X)/S.nullable(X), but only when exactly one member was left. That rule now covers any count: null and undefined are tested first on both values, and the rest of the union dispatches only once each value is known to be neither. No discriminant read ever sees either value, so the?.#461 added is dropped. That leaves one mechanism instead of two.compareis unchanged: a union with more than one member of substance still has no order and still refuses.What changes for you
Comparing values of a union that holds
S.envno longer crashes, andcompareon a tuple with anS.envslot orders by every slot.X | nullunions already answered right onmain; they now compile to the split form above.Impact (bundle vs main)
isEqual*/compare*answer is unchanged.compare*+27 B,isEqual*+21/+22 B,total73883 -> 73881 (-2).spec check --perf=onlyshows no significant change, as it times parse and creation, not comparators.Decision
Two ways to fix the env crash: (a) this PR's split of null/undefined off every union comparator, or (b) main's discriminant
?.withS.envadded to the members that trigger it, plus the same env compare leaf fix. Both answer identically on every spec and both fix both bugs. Measured on the merged branch (isEqualOutput over every value pair, best of 25 runs, ns/call, two runs each):?.+ envA | B | null(tagged)optional(A | B)(tagged)A | B | S.env(tagged)optional(number | string | object)nullable(number | string | boolean)isEqual*/compare*vs main(b) is smaller, but positive-flow speed ranks above bundle size, and (a) is 1.2-2.3x faster on every tagged or optional union because one up-front
a===void 0/a===nullreplaces a?.on each discriminant read of both values. Creation+compile time is within noise for both. Kept (a).Details
eq-tagged-union-envandcompare-tuple-envhold the two bugs.eq-tagged-union-nullable,union-tagged-optional,fromjsonschema-allof-base-schemaand the protobuf oneof specs take the split form; about 30env/codec-env-*/optional-env-*specs take the new env compare leaf(b===void 0)-(a===void 0)||(a<b?-1:a>b?1:0).fuzz:schema(eq laws, compare antisymmetry and agreement withisEqual) andfuzz:union --seed=1report no findings.fromjsonschema-allof-base-schema.yaml,bundleSize.yamland the benchmark goldens took main's side and were regenerated;eq.tsmerged cleanly.pnpm verifypasses, every step.S.optional(S.env)/S.nullable(S.env)compare, the env leaf still re-testsundefinedafter the union split it off. Redundant, never a wrong answer, and already present onmain.🤖 Generated with Claude Code
https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Summary by CodeRabbit
Bug Fixes
null,undefined, and missing selectors.undefinedandnullare compared.New Features
Chores