Repository navigation
A fallback past a type's last constructor goes to --verdict as \{}, as bend2 skips it, so a ~ argument or a type that has one checks (#1204) - #1246
Merged
Conversation
nicolas-abril
force-pushed
the
closed-tmpl-args
branch
from
October 1, 2026 17:27
4aa6bfd to
177a72a
Compare
nicolas-abril
force-pushed
the
closed-tmpl-args
branch
from
October 1, 2026 18:10
177a72a to
3a36b5e
Compare
…s bend2 skips it, so a ~ argument or a type that has one checks (bendlang#1204) bend2 skips a default past the last constructor (dead code, WONTFIX), and its checked terms hold \{} there. A bare term the elaborator types itself, a term in a type or a ~ argument read back from book.tmps, kept the written default, which the elaborator could not type: the def went out of scope ("an application with no known head type") and --verdict reported a mismatch where bend2 checked. swi now takes that default as \{}. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
nicolas-abril
force-pushed
the
closed-tmpl-args
branch
from
October 1, 2026 19:04
3a36b5e to
785bdc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1204.
What #1204 comes down to
A
~argument with a caller's variable in a fallback past the last constructor, like\{Unit: 0n; x}, passes the closed-argument guard. That's because the checker skips dead code ("The checker skips dead code" inWONTFIX.txt). Two callers whose arguments differ only there,g(x: Nat)andh(x: Bool), then share one instance. That is harmless: the interpreter, JS and C all print the right value, because the dead arm never runs.The real bug is
--verdict. It reports a mismatch on these programs, and also on a closed argument like\{Unit: 3n; 0n}. It has nothing to do with templates either: the same dead fallback inside a type fails the same way.The cause
bend2's checked terms already hold
\{}where the checker skipped a dead default (check-mat), and the elaborator reads those. But it elaborates some terms bare, typing them itself:~arguments, whichsafe_bookreads back frombook.tmps.In those,
swielaborated the written default, couldn't type it, and dropped the def ("an application with no known head type").The change
switakes a default past the last constructor as\{}, the same rule ascheck-mat(rem.length === 1 && tm.m.$ !== "Mat"). Likecheck-mat, it tests the default's raw tag, so an annotated match there ({\{Unit: 1n} : Unit -> Nat}) is a dead fallback too, and only a bare match continues the chain. That's two lines insafe.ts, andbend.tsis untouched.Checks
New tests, which print the same value in the interpreter, JS and C:
--verdictonmain--verdictheretests/proof/dead_fallback_type: a dead fallback in a type, no template, written plainly and as an annotated match3nSOME PROOFS FAILALL PROOFS CHECKtests/comptime/dead_arm_shared: def_inst reuses template specializations across unrelated functions due to un-scoped term_key collisions #1204's two callers0nSOME PROOFS FAILALL PROOFS CHECKgates/safe.tswould report both as false rejects onmain.No change elsewhere: for all 1606
.bendfiles undertests/,bench/anddemos/, the--check-onlyoutput, emitted.c,.js,.bendttand every log are identical tomain(1606 files, 8995 outputs compared). No existing program had a dead fallback in a bare term.Gates:
tscgives the same 12 errors asmain.gates/repo.tspasses, 50 / 50.safe.tsgoes from 20,244 to 20,280 ttok.Not run: the cluster gates,
gates/safe.tsincluded.🤖 Generated with Claude Code