Skip to content

Fix widening Result variants with never payloads - #1172

Open
blurname wants to merge 1 commit into
vercel-labs:mainfrom
blurname:fix/never-result-widening
Open

blurname wants to merge 1 commit into
vercel-labs:mainfrom
blurname:fix/never-result-widening

Conversation

@blurname

@blurname blurname commented Oct 17, 2026 •

Copy link
Copy Markdown

Fixes #1170.

Widening Result<T, never> to Result<T, E> (and the symmetric error-only result) currently fails because the unreachable payload uses the numeric placeholder and is checked as an inhabited record arm.

Track uninhabited record arms as part of union identity and preserve that information through optionality and union transformations. The existing retag planner can then trap an impossible arm instead of requiring an incompatible payload conversion. Keep the original layout so unreachable branch reads still compile; an inhabited alternative sharing the same storage layout prevents that arm from being marked impossible.

Regression coverage includes both result variants, arguments and returns, nested records and arrays, intersection records, optional never, never[], never-returning callbacks/accessors, storage-identity collisions, and IR validation/serialization. The differential fixture runs against Node in release and dev modes.

Validation on macOS arm64 with Node 24.22.0:

  • Workspace build, lint, formatting, and baseline completeness checks pass.
  • On the standalone branch, all 205 tests in type-mapper-unions.test.ts, union-retag.test.ts, and validate.test.ts pass; the new differential fixture passes in release/dev and plain/ASan+RC-audit modes.
  • Affected TypeScript preflight/order parity batches pass.

Full-gate status: not green. A full local plain run was stopped after the existing WASI test the LLVM target embeds compressed npm sources and builtin shims failed with Buffer.concat of 'unknown' values (SC2020, zlibzoo/index.js:52). The identical failure reproduces with all affected compiler sources loaded from the unchanged base 1b34b4069a235d4d911783cb652fcd87e3bd5db0 and caches disabled. The full sanitized lane has not completed; the targeted sanitized regressions listed above pass. No test is disabled or changed to hide this baseline failure.

The two fixes are on independent branches; the full-gate attempt included both, while focused validation was also run on each standalone branch.

@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@blurname is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@blurname
blurname marked this pull request as ready for review October 17, 2026 06:25

This branch has not been deployed

No deployments
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.

SC2003 rejects widening Result<T, never> and Result<never, E>

1 participant