fix(grainfmt): Correct formatting of record assignments#2344
Merged
spotandjake merged 1 commit intoJan 16, 2026
Merged
Conversation
ospencer
approved these changes
Jan 16, 2026
I noticed that `at.y.x += 10` was being formatted as `at.y.x = at.y.x + 10` this was because we only checked one level deep on record assignments. While fixing this I also noticed that we compared the identifier directly on patterns such as `at.y += 10` which means that `at.y += 10` gets formatted as `at.y += 10` however `at.y = at.y + 10` doesn't get collapsed due to the locations on the identifier differing. Closes: grain-lang#2343
c9d889b to
66089be
Compare
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.

I noticed that
at.y.x += 10was being formatted asat.y.x = at.y.x + 10this was because we only checked one level deep on record assignments. While fixing this I also noticed that we compared the identifier directly on patterns such asat.y += 10which means thatat.y += 10gets formatted asat.y += 10howeverat.y = at.y + 10doesn't get collapsed due to the locations on the identifier differing.Closes: #2343