Repository navigation
Conversation
`S.union([S.string, S.object((s) => ({ a: s.field("a", S.never) }))])` would
not compile an encode ("Missing input for never at a"), and neither would the
object alone, while `S.schema({ a: S.never })` compiles and rejects every
value at runtime, as a schema nothing inhabits should.
A shaped object's encode finds where each Output field came from by walking
the decoded vals and reading each val's expected schema, the `s.field` proxy
that carries the location. `S.never`'s decoder ends its val's chain on
`never_` so nothing after it runs, and that replaces the proxy, location and
all. The walk now reads the location off the container's own field schema,
which is the same proxy for every other field and is still there for this one.
The never field then encodes like the plain object's: it compiles, rejects any
value with "Expected never", and inside a union yields to the string member.
Known bug `union-never-member` is deleted; its spec now encodes "x" (encode is
the same code as parse), and `object-field-never-renamed` pins a renamed never
field, whose encode reads `b` back into `a`. Bundle: `object` +9 gzip.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Spec performance1 slower of 3741 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 3.9% · run 3.4% · scenario 3.0% |
…-cases-u2dnpj-never-field # Conflicts: # packages/benchmarks/goldens/schema.json # packages/sury/specs/bundleSize.yaml
Spec performanceNo significant changes of 3856 timed targets · Not timed
+% slower than baseline, -% faster · noise floor create 4.1% · create+compile 6.3% · run 3.0% · scenario 3.7% |
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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XdDnkN38pECC46XqMZbwp8
Spec performance1 slower of 3883 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 3.4% · create+compile 3.1% · run 7.3% · scenario 9.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 performance1 faster of 3956 timed targets · Not timed
Faster
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 7.1% · run 3.9% · async 3.0% · scenario 4.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
knownBugs.ts takes main's version less this branch's union-never-member entry; generated files 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 4235 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 3.8% · create+compile 3.0% · run 3.0% · async 3.3% · scenario 11.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 4257 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 3.0% · run 4.3% · async 3.0% · scenario 3.0% |
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 4257 timed targets · Not timed
Slower
+% slower than baseline, -% faster · noise floor create 3.0% · create+compile 4.9% · run 3.0% · async 3.0% · scenario 14.1% |
Main settled union-never-member its own way (#490), so its spec and the union-never-member-yields knownBugs entry take main's side. What stays is the renamed-field fix: S.object(s=>({b: s.field("a", S.never)})) now compiles its encode and rejects with "Failed at b: Expected never, received 1" instead of failing at creation with "Missing input for never at a". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
The limitation stood because the union fuzzer's member-by-member reference met an object with an `S.never` field alone, where its encode refused to compile. Reading a shaped field's location off its container lets that object compile and reject at runtime, so the reference agrees with the union and the gate no longer reaches the entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Spec performance3 slower, 1 faster of 6476 timed targets · Not timed
Slower
Faster
+% slower than baseline, -% faster · noise floor create 4.9% · create+compile 4.5% · run 3.0% · async 3.0% · scenario 3.0% |
Cause
A shaped object's encode finds where each Output field came from by walking the decoded vals and reading each val's expected schema, which is the
s.fieldproxy that carries the location.S.never's decoder ends its val's chain onnever_, so nothing after it runs. That replaces the proxy, and the location goes with it.Fix
The walk now reads the location off the container's own field schema. For every other field that's the same proxy the val carried (checked), and for a
neverfield it's still there.I tried the obvious alternative and rejected it: keeping the caller's expected schema in the never decoder broke
codec-array-never-jsonstring. Ending the chain is deliberate there, since it's what stops a link afterneverfrom compiling a conversion for a value that can't exist.What changes for you
mainalready fixed the union case (#490). This PR now fixes only a renamedneverfield:S.union([S.string, S.object((s) => ({ a: s.field("a", S.never) }))])gives the same answer as onmain: parse, decode and encode are alltypeof i==="string", and{ a: 1 }is rejected withExpected string | { a: never; }, received { a: 1; }.Impact (bundle vs main)
Gzip bytes:
object+18 (13235 to 13253),shape+15,tuple+15,protobuf+21,protobufAny+19, total +21 (73883 to 73904). The benchmark goldens moved by the same amounts. No other export moved.Decision
main's Fix the critical and most important bugs from the FIXME and known-bug triage #490 made a union member with aneverfield yield to its siblings, sounion-never-member.yamltakesmain's side and this PR no longer changes it.mainlisted the remaining fuzzer difference as the limitationunion-never-member-yields: the member-by-member reference met the object alone, and its encode refused to compile. With this fix that object compiles and rejects at runtime, so the reference agrees with the union and the gate stopped reaching the entry. The entry is deleted, as the gate requires.Details
object-field-never-renamed(new). Withmain'ssrcits encode becomescreationError: "SuryError: Missing input for never at a"; with this branch it readsbback intoaand fails withFailed at b: Expected never.origin/main(2ebcac6) as a merge commit.knownBugs.ts,union-never-member.yamland the generated goldens tookmain's side and were regenerated after that. The changes infactory.ts/parse.tsmerged cleanly.pnpm verifypasses on ea83f23, every step including the ppx build, e2e, every fuzzer and the protobuf suites.🤖 Generated with Claude Code
https://claude.ai/code/session_01X9uDwr3yJ2L75BYdetqyE1
Summary by CodeRabbit
never, including when those fields are nested in objects or tuples.never.