Repository navigation
fix(lint): use parsed declarations in formatting guard - #1477
Open
vicmcorrea wants to merge 1 commit into
Open
vicmcorrea wants to merge 1 commit into
vicmcorrea wants to merge 1 commit into
Conversation
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.
Problem and fix
Bend accepts indented top-level declarations, but bundled bend-lint misses their names when rebuilding the declaration-comparison seed. Even comparing the original source with itself fails, so
--fixrefuses safe formatting of valid indented definitions, types, laws, and proofs.Record the root parser's declaration keys through the existing in-memory seam and use them to rebuild the seed. Comparison-only parsing suspends and restores the observer, including on parse failures, so overlapping rules cannot overwrite another check's declarations. This adapts the parser-derived formatter guard from MattCozendey's standalone bend-lint change.
Blast radius
tools/bend-lint/src/seam.ts: observes parser declaration keys during lint checks and changes the seed used bysameDeclarations. This affects rules using that comparison, including theformat/layoutsafe-fix guard. Snapshot comparisons restore the active observer on success and failure.tools/bend-lint/rules/format.test.ts: adds regression coverage for indented declarations, semantic changes, multiline literals, and overlapping rules.Only these two bundled-tool files change. The formatter layout engine, language/compiler sources, generated-program runtimes, and gates are unchanged. Tests remain in bend-lint's own suite, following the maintainer guidance in #1389.
Regression evidence
7, and a second lint run is clean.Checks
c9b3283.git diff --check: passed.Validation limits
Typecheck is not clean on main or this branch: both report the same two pre-existing TS2339 errors in protected
bend2/bend.tsat lines 2040 and 3771. No new typecheck diagnostics were introduced.Local tests ran on macOS arm64 with Bun 1.3.11. Windows and the cluster gates were not run. The additional in-memory parser hook depends on the current
parse_booksignature and declaration ordering; signature, startup, and patch-drift checks cover that dependency.