Skip to content

fix(lint): respect module headers in declaration guard - #1460

Merged
Lorenzobattistela merged 1 commit into
bendlang:mainfrom
vicmcorrea:fix/lint-header-guard
Oct 10, 2026
Merged

Lorenzobattistela merged 1 commit into
bendlang:mainfrom
vicmcorrea:fix/lint-header-guard

Conversation

@vicmcorrea

@vicmcorrea vicmcorrea commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

bend-lint refuses safe formatting when a valid module-import header is indented. Its declaration guard also removes import-looking lines throughout the file, so it can miss changes inside multiline strings or reject unchanged foreign-function bodies.

Limit masking to the initial module-import header, following book_load's whitespace, comment and boundary rules. Recover fallback aliases from that same header while preserving parser-observed aliases. This adapts the standalone bend-lint correction to the bundled tool. Tests stay in bend-lint's suite, following the maintainer guidance in #1389.

Blast radius

  • The production change is confined to sameDeclarations in tools/bend-lint/src/seam.ts. It affects rules that use this guard, including the formatter's safety check.
  • Only initial import Base and import path as Alias header lines are masked. Scanning stops at the first body line, including @unsafe. Foreign imports, later imports and multiline literal contents remain part of the comparison.
  • The guard still compares parsed declarations using the already checked imports. Module loading, compiler/checker code and formatting rules are unchanged. The other changed file contains seven regressions in rules/format.test.ts.

Validation

  • bun test from tools/bend-lint passes all 122 tests. Each of the seven new regressions fails against the original guard.
  • Actual CLI checks cover LF/CRLF, indented Base and module imports, foreign imports, and imported-law proofs. Safe fixes match the expected text, a second lint is clean, and tested source/emitted-JS output remains 7.
  • bun gates/repo.ts passes 54/54. git diff --check passes.

Validation limits

Typecheck still reports the same two pre-existing TS2339 errors in bend2/bend.ts, at lines 2040 and 3771. The before/after diagnostics are identical. These checks cover the bundled linter and tested programs; full cluster gates were not run.

@Lorenzobattistela
Lorenzobattistela merged commit 73c0ac8 into bendlang:main Oct 10, 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