Skip to content

Commit ba9bf0f

Browse files
kim-emclaude
andcommitted
fix(lint-style): filter out duplicate Init from Mathlib.lean imports
`Lean.parseImports'` now emits `Init` more than once for module-system files such as `Mathlib.lean`, but `findImportsFromSource` (in importGraph) only `.erase`s the first occurrence. The remaining `Init` was treated as a module to lint, producing `uncaught exception: no such file or directory ... file: Init.lean` and breaking the `lint-style` CI job on `nightly-testing`. Defensively filter out any remaining `Init` after `findImportsFromSource`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aaa0ccc commit ba9bf0f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/lint-style.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def missingInitImports (opts : LinterOptions) : IO Nat := do
105105

106106
-- Find any file in the Mathlib directory which does not contain any Mathlib import.
107107
-- We simply parse `Mathlib.lean`, as CI ensures this file is up to date.
108-
let allModuleNames := eraseExplicitImports (← findImportsFromSource "Mathlib.lean")
108+
-- Note: `findImportsFromSource` only erases the *first* occurrence of `Init`.
109+
-- On module-system files (such as `Mathlib.lean`), `Lean.parseImports'` may emit
110+
-- `Init` multiple times, so we filter out any remaining occurrences here.
111+
let allModuleNames := (eraseExplicitImports (← findImportsFromSource "Mathlib.lean")).filter
112+
(· != `Init)
109113
let mut modulesWithoutMathlibImports := #[]
110114
let mut importsHeaderLinter := #[]
111115
for module in allModuleNames do

0 commit comments

Comments
 (0)