Repository navigation
fix(cli): an error in a def with a ~ parameter names its own file, not base.bend - #2286
Merged
Merged
Conversation
book_location looked for any tld marked b typed in the span's file, which a def's ~ parameters also match. Base's Bool is enough: only Base's parse holds it, and a file without Base has no Bool marked b. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
to nicolas-abril/bend
that referenced
this pull request
Nov 24, 2026
, bendlang#2224-bendlang#2226, bendlang#2231, bendlang#2285, bendlang#2286, bendlang#2288 and others) One conflict, in emit_unfold: bendlang#2288 annotates an unfolded call's lets with the argument types instantiated by the earlier arguments; bendlang#2162's deep unfold keeps its arguments unannotated there and annotates them the same way after folding (its type walk renamed D, beside bendlang#2288's T). Both kept. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Since #2208, a CLI error ends with
--> file:line:col. For an error in a def with a~parameter, that line namesbend2/base.bendinstead of the file the error is in:The excerpt and the caret are right. Without the
~, the last line is--> f.bend:4:3. The line and column are the user file's, so thebase.bendlocation is often a blank line or a column past the end of its line. In a file that doesn't import Base, the-->line is missing entirely.Why
book_locationdecides a span is Base's when some tld markedbhas a type in the span's file.def_checkchecks a def with~parameters in a book of its own: each parameter becomes a tldf~xmarkedb: true, typed in the def's own file. That book's tlds inherit the others through the prototype, soObject.valuessees only those parameter tlds, and they match.What changes
book_locationwalks the inherited tlds too (for … in) and skips names with a~. The other locations are unchanged: an error in an imported file, in the entry, at a missing import, at a template call site likeList.map(~U32, ~U32, ~(x => True{}), xs), and in Base itself. For the last one, I appended a broken plain def and a broken template def to a copy of base.bend, and both still printbase.bend:<line>:<col>.tests/io/cli_source_locationgains the case above: it returns 3 on main and 0 with this change, on the interpreter and on Bun.Verified
Linux x86_64, Bun 1.4.0:
--check-onlyon all 1,882.bendfiles undertests/with and without this change. 1,880 print the same output. The other two are existing tests that hit this bug,tests/comptime/err_generic.bend(--> bend2/base.bend:8:3) andtests/page/comp_param_match.bend(--> bend2/base.bend:13:10). With the change, each names its own file at the same line and column. Their#|lines don't include the-->line, so their expected output is unchanged.main.tsgrows by 226 characters. I could not runttokhere. By characters,main.tsis about 13k tokens against its 16k cap.