Skip to content

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

Merged
Lorenzobattistela merged 1 commit into
bendlang:mainfrom
vicmcorrea:fix/lint-parsed-declarations
Oct 15, 2026
Merged

Lorenzobattistela merged 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

  • Original PR head (c9b3283, October 10) bend-lint suite: 126 passed, 0 failed; 827 assertions.
  • Original-head local repository gate: 54/54, using CI-pinned ttok 0.3.
  • GitHub repo-gate: passed on c9b3283.
  • git diff --check: passed.

Validation limits

On October 14, the tools/bend-lint suite on main dbb3157 reports 109 pass / 9 fail / 1 error; a private merge of this PR with that main reports 113 pass / 9 fail / 1 error. Existing failing test names and diagnostics match, and all four added regressions pass. Both runs hit Base's new Event.Text constructor colliding with bend-lint's existing Value.Text after #1441. This main regression is outside the declaration-guard change.

The original base and PR head also had the same two pre-existing TS2339 errors in protected bend2/bend.ts at lines 2040 and 3771. No new diagnostics were introduced in that comparison; typecheck was not rerun on the latest main.

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.

@Lorenzobattistela
Lorenzobattistela merged commit 9fef86b into bendlang:main Oct 15, 2026
1 check passed
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.

2 participants