Skip to content

Revert the checked-cast fallback (#1561); keep the optional-chain fix - #1601

Merged
ctate merged 2 commits into
mainfrom
opt/revert-checked-cast-fallback
Oct 21, 2026
Merged

ctate merged 2 commits into
mainfrom
opt/revert-checked-cast-fallback

Conversation

@cramforce

Copy link
Copy Markdown
Contributor

Reverts #1561 (6bb2711) and keeps its one unrelated fix.

Why

scriptc's premise is that types don't lie. #1561 made a checked cast whose value does not fit its type (JSON.parse(text) as T, const x: T = anyValue) continue in a dynamic copy of the code after it, so a program could keep running on data that contradicts its own types. That was a misdirection: a mismatch should stay a TypeError naming the path, and programs and test fixtures should declare types that match their data. This restores the checked-cast behavior and its documentation (the runtime type checks section, the limitations page and --tier) to what they were before #1561.

What stays

a?.b.c on an any value short-circuits only on the guarded step: it is undefined when a is nullish and throws when a is present but a.b is undefined, as in Node (before #1561 it answered undefined). That piece is re-applied as its own commit with a new corpus program, optional-chain-any-tail.ts, identical to Node in both lanes. corpus/1544-dyn-json-reads.ts keeps its #1561 binary.

Nothing merged after #1561 used it: no references to scr_dyn_check_recover, checked-fallback.ts, the checkedCast.* builtins or the fallback JSON helper remain.

Validation

🤖 Generated with Claude Code

cramforce and others added 2 commits October 20, 2026 16:42
…il (#1561)"

This reverts commit 6bb2711, reversing
changes made to cd833e6.
`a?.b.c` on an `any` value answered undefined when `a` was present and
`a.b` undefined: every later step of the chain read optionally. Node
short-circuits only on the guarded receiver and throws reading `.c`.

An `any` receiver now makes the tail an optional chain like a dyn one,
and inside the chain's guarded body the consumed `?.` no longer marks
the later dynamic reads optional. (Kept from #1561, whose checked-cast
fallback is reverted.)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 21, 2026 12:43am UTC

@ctate
ctate merged commit aec7758 into main Oct 21, 2026
23 checks passed
@ctate
ctate deleted the opt/revert-checked-cast-fallback branch October 21, 2026 00:46

This branch was successfully deployed

1 active deployment
Preview — 22b9db26 Deployed Oct 21, 2026 by vercel[bot]
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.

2 participants