Skip to content

feat: add requiresModuleSystem package option in Lake#13646

Draft
Kha wants to merge 2 commits into
leanprover:masterfrom
Kha:push-pyroqqmuvwnt
Draft

feat: add requiresModuleSystem package option in Lake#13646
Kha wants to merge 2 commits into
leanprover:masterfrom
Kha:push-pyroqqmuvwnt

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented May 5, 2026

This PR adds a new Lake package option requiresModuleSystem. When a package sets it to true, Lake emits a warning whenever a non-module-system file (one without a module header) imports a module of the package, both from downstream consumers and from non-module files within the package itself. This signals that the package's API expects the visibility and elaboration semantics of the module system. A companion option allowNonModules lets an importing package opt out of these warnings, declaring that it knowingly mixes non-module-system files with module-system dependencies.

This PR adds a new package configuration option `requiresModuleSystem`. When a
package sets it to `true`, Lake emits a warning whenever a module from another
package imports any of its modules without itself using the module system
(i.e., without a `module` header). This lets package authors signal that their
API is designed for the visibility and elaboration semantics of the module
system.

The check lives in `fetchImportInfo` and runs once per import after resolving
the providing module(s); the disambiguation case (multiple packages providing
the same module name) warns if any provider has the flag set.
@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 5, 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-03 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-05 15:31:51)

@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 5, 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 5, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

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

Mathlib CI status (docs):

This PR adds a companion configuration option `silenceRequiresModuleSystemWarning`
that lets a package opt out of the warning emitted by Lake when it imports
modules from a `requiresModuleSystem` dependency without using the module
system. This is intended for packages that have knowingly decided not to
migrate to the module system yet.

The flag is honored by `fetchImportInfo` via a new `silenceWarning` parameter
threaded from the importing module's package configuration.
mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request May 6, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request May 6, 2026
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 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.

2 participants