Repository navigation
fix(lint): format a glued < that no > closes instead of throwing - #2231
Merged
Merged
Conversation
tokens() split every <- glued after a name, and tree() opened type arguments at every < glued after a name, so x<- m and (a<4 : U32) left a group open and format/layout threw 'unbalanced delimiters'. <- is now split only when no space follows it (Box<-T), and a < group that a closer or the end of the file reaches first gives its tokens back to the enclosing group. 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.
format/layoutthrows on a file that checks when a<glued to a name is not a type argument.bend-lintthen exits 2 and writes nothing, although the fix is marked safe:(a<4 : U32)in a def body does the same. Removing the one space before<-in a repository file, such as line 92 oftests/base/read_bounds.bend, is enough to reach it.Why
tokens()splits a<-glued after a name into<and-, so thatBox<-Topens type arguments.tree()then opens a group at every<glued after a name. InUnit<- manda<4no>closes that group, sotree()throws at the end of the file.What changes
tokens()splits<-only when no space follows it, as inBox<-T.Unit<- mstays a bind and formats asUnit <- m.tree()gives a<group's tokens back to its enclosing group when a),],}or the end of the file comes before its>.(a<4 : U32)formats as(a < 4: U32), as(a < 4 : U32)already does.Unit<-mstill splits. The rule's parse check now reports it without a fix instead of throwing.Verified
Linux x86_64, Bun 1.4.0:
bun test rules/format.test.tspasses 40 tests. The new test fails on main with the thrown error.--fixon every.bendundertests/,bench/anddemos/(1,957 files) gives byte-identical files and exit codes with and without this change.--fixchanges nothing.