Skip to content

feat: public imports for environment linters inside of lake lint in module system mode#13843

Merged
wkrozowski merged 2 commits into
leanprover:masterfrom
wkrozowski:wojciech/envLinterPublicImport
May 27, 2026
Merged

feat: public imports for environment linters inside of lake lint in module system mode#13843
wkrozowski merged 2 commits into
leanprover:masterfrom
wkrozowski:wojciech/envLinterPublicImport

Conversation

@wkrozowski
Copy link
Copy Markdown
Contributor

@wkrozowski wkrozowski commented May 25, 2026

This PR makes lake lint --builtin-lint import module-system targets at the public (OLeanLevel.exported) level instead of private. Environment linters now lint the public surface of such modules, matching how downstream consumers see them. Non-module targets retain their previous behaviour (private level), and text-linter warnings recorded via lintLogExt are preserved across the level change because that extension stores uniform OLean entries.

The top-level module's .olean is peeked via findOLean + readModuleData to decide whether to use .exported or .private, mirroring processHeaderCore. A new tests/lake/tests/builtin-lint-module/ test exercises the new code path with a dummy env linter and verifies that text-linter warnings on both public and private definitions survive the level switch.

@wkrozowski wkrozowski requested a review from tydeu as a code owner May 25, 2026 17:13
@wkrozowski wkrozowski added changelog-lake Lake lake-ci Run all Lake tests labels May 25, 2026
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label May 25, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-05-25 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-05-25 18:12:41)

@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label May 25, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label May 25, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

mathlib-lean-pr-testing Bot commented May 25, 2026

Mathlib CI status (docs):

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request May 27, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request May 27, 2026
@wkrozowski wkrozowski added this pull request to the merge queue May 27, 2026
Merged via the queue into leanprover:master with commit bf38e59 May 27, 2026
19 checks passed
let modFile ← findOLean mod
let (modData, region) ← readModuleData modFile
let isModule ← getIsModule modData
let level := if isModule then OLeanLevel.exported else OLeanLevel.private
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level should be irrelevant for non-modules (they only have a single scope) so you should be able to just always pass exported

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, that makes sense! Let me fix that.

Copy link
Copy Markdown
Contributor Author

@wkrozowski wkrozowski May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so when I always pass .exported I get "error: cannot import non-module Main from module".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a non-module top-level file Main.lean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that probably makes sense. It really should only be this final check though, I wonder if we should create an opt-out to simplify tooling

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

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-lake Lake lake-ci Run all Lake tests mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants