Repository navigation
The verdict walks from every law, whichever file fills it, so an unsafe fill in an imported file is listed - #1033
Merged
Conversation
…fe fill in an imported file is listed (bendlang#1001) Since bendlang#848, cli_report walked only the entries of the file under check (book.order from n0). A law is declared in one file and may be filled in another: a fill in a module PROOF.bend imports (Helper.bend filling LAWS.false_law with an @unsafe self-call) sat outside that range, the root never names the law, and `bend PROOF.bend` printed a clean "All terms check." while the false law proved every other law with no further unsafe. The walk's roots are now the file's own entries plus every law outside Base. A law is the key book.order holds twice (its declaration, then its fill; book_valid reads the order the same way), so no name or namespace picks it: a file that registers keys under LAWS. (bendlang#1002) can add laws to the walk, never hide one, and an unfilled law still fails as a TODO first. The rule matches the TODO check, which already makes every open law in the book the verdict's business wherever it is declared. The root's entries come first, so a listing whose fills are all in the root is unchanged. Importing still does not contaminate: an @unsafe def that neither the file nor any law names stays silent. Exit codes do not change (bendlang#776, bendlang#805). Tests (tests/import, modules in unsafe-law/): unsafe_law_fill, the fill in an imported file, is listed; unsafe_law_derived, a law proved from the unsafe one, lists both laws and not the helper; unsafe_law_unused, a safe fill beside an unused @unsafe def, stays clean; unsafe_law_own, the fill in the file under check, prints what it printed before.
nicolas-abril
approved these changes
Sep 24, 2026
nicolas-abril
left a comment
Collaborator
There was a problem hiding this comment.
Thank you, this is right. Checked on main (ac0ddb7b) with this branch merged:
- The issue's repro prints
All terms check.on main and listsLAWS.false_lawhere;unsafe_law_fillandunsafe_law_derivedfail on main and pass here,unsafe_law_unusedandunsafe_law_ownpass on both. - The order argument holds:
parse_deffills a law only while it is unfilled and sends every other def throughparse_fresh, so a key is ordered at most twice, and only as a law's declaration and fill. A law filled by a foreign body is refused by the checker, so that route stays closed too. - The gate's check/interp pass over every test: the 1441 existing sections are byte-identical to main, and all 1445 match their
#|lines. All 50 demo files give the same--check-onlyoutput, andbun gates/repo.tspasses 46/46.
Note: this review was written by an AI after it tested the PR for me and I reviewed the findings. If anything here is wrong, reply and I will review it myself.
Merged
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.
Fixes #1001.
Why
Since f1d23d3 (#848),
cli_reportwalks the references of the file under check only:book.order.slice(n0). A law is declared in one file but can be filled in another. In the issue's repro,Helper.bendfillsLAWS.false_lawwith an@unsafeself-call andPROOF.bendonly imports Helper. The fill is pushed into Helper's part ofbook.order, and the root never names the law, so the walk never reaches it.bend PROOF.bendprinted a cleanAll terms check.(exit 0), and the false law then proved every other law with no further unsafe.The fix
One change in
bend2/main.ts(cli_report): the walk's roots are the file's own entries plus every law outside Base.A law is identified by the order, not by its name.
book.orderholds a law's key twice: once at its declaration and once at its fill.book_validreads the order the same way (the first event checks the law's type, the last defines it). A def or type is pushed once, and template instances stay outside the order. So:LAWS.namespace (Names resolve to keys other files register under the importer's namespace: an app file can rewrite what LAWS.bend says, or make PROOF.bend check different code thanbend main.bendruns #1002) can add laws to the walk. It cannot hide one: the declaration always pushes the key, the fill always pushes it again, and an unfilled law fails as a TODO before the report runs.b === true), as before.The fix adds 74 tokens to
main.ts(9616 → 9690, cap 10000).bend.tsis untouched.All terms check.- LAWS.false_lawsucc_is_idderived in Helper)All terms check.- LAWS.false_law,- LAWS.succ_is_id- LAWS.false_law- boom,- LAWS.succ_is_id- LAWS.false_law, which the old listing omitted though it holds only by the unsafe fillWhat stays the same
@unsafedef that neither the file nor any law names stays silent. Only laws join the roots, not every def of an imported file.bend PROOF.bendexits 0 with@unsafein the import graph, and checks only the laws it happens to import #776, The @unsafe count is disclosed only on the no-main path: a harmless main, or any -o emit/build, reports nothing #805). Only the note does.bend main.bendon a file that imports an unsafely filled law now prints the same note on stderr before the run. That case had the same gap: before, the note was missing and the run printed only its result.Tests
The four root tests are in
tests/import/. The modules they import are intests/import/unsafe-law/, so the gate doesn't read them as tests.unsafe_law_fill: the issue's repro 1. The unsafe fill is in an imported module, and the verdict lists the law.unsafe_law_derived: the issue's repro 2. A second law is proved from the unsafe one with no@unsafeof its own. Both laws are listed; the helperboomis not.unsafe_law_unused: a law filled safely beside an@unsafedef that nothing names. The verdict staysAll terms check.unsafe_law_own: the unsafe fill is in the file under check. The output is the same as onmain.Validation
bend main.bend --checkupover all tests, with each section compared to its#|lines. That is the gate's check and interp probes; the C and JS lanes did not run.tests/io/tcp_send_slow_peeris left out, as the gates leave it out.mainwith the new tests added: 1442 / 1444. The two failures areunsafe_law_fillandunsafe_law_derived, which printAll terms check..demos/*/*.bendprints the same--check-onlyoutput onmainand with the fix. That covers the ten PROOF/LAWS pairs,app_slash_boss_3d(which importsbend3d.bend) and the netcode files. No bench imports a local module.gates/repo.tspassed, 46 / 46.