Skip to content

fix(lint): use parsed declarations in formatting guard - #1477

Open
vicmcorrea wants to merge 1 commit into
bendlang:mainfrom
vicmcorrea:fix/lint-parsed-declarations
Open

vicmcorrea wants to merge 1 commit into
bendlang:mainfrom
vicmcorrea:fix/lint-parsed-declarations

Conversation

@vicmcorrea

@vicmcorrea vicmcorrea commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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 --fix refuses 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 by sameDeclarations. This affects rules using that comparison, including the format/layout safe-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

  • The three new declaration regressions fail against the original seam. They cover spaces/tabs, LF/CRLF, definitions, types, local/imported proofs, and unsafe declarations. Controls reject changed values, added/removed declarations, and changed literal contents.
  • Removing only observer suspension makes the overlapping-rule regression fail. The corrected implementation also handles malformed comparison input without contaminating another check.
  • Real CLI checks reproduce main's refusal and verify the safe fix on this branch. Execution remains 7, and a second lint run is clean.

Checks

  • bend-lint suite: 126 passed, 0 failed; 827 assertions.
  • Local repository gate: 54/54, using CI-pinned ttok 0.3.
  • GitHub repo-gate: passed on 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.ts at 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_book signature and declaration ordering; signature, startup, and patch-drift checks cover that dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant