fix(modgraph): partition import resolves to base module, not own partition#14
Merged
Sunrisepeak merged 1 commit intomainfrom May 9, 2026
Merged
Conversation
…ition
When a module-interface unit imports a sibling partition with `import :foo`,
the scanner prepended its own `provides->logicalName` as-is. For a primary
interface (`export module M;` → logicalName "M") that's correct: "M:foo".
But for a *partition* unit (`export module M:bar;` → logicalName "M:bar")
the same code produced "M:bar:foo" — which no other TU provides, so GCC's
dyndep step prints a benign-but-noisy
warning: <file>: module 'M:bar:foo' imported but not provided in this build
(the build itself still succeeds because GCC resolves the import via its
own scan; mcpp's warning comes from comparing scanner output to the
producer map).
Fix: strip our own `:partition` suffix from the base before prepending.
before: M:bar + ":foo" → "M:bar:foo" (wrong)
after: "M" + ":foo" → "M:foo" (correct sibling)
Reproduced under mcpplibs/tinyhttps where `http.cppm`'s
`export module mcpplibs.tinyhttps:http;` plus its `import :tls; import
:socket;` etc. produced 7 stale "imported but not provided" warnings on
every build. After this patch, `mcpp build` of tinyhttps is
warning-free.
Coverage: three new unit tests in `test_modgraph.cpp`:
- `Scanner.PartitionImportFromPrimaryInterface` (regression guard
for the working case)
- `Scanner.PartitionImportFromAnotherPartition` (the actual bug)
- `Scanner.PartitionImportWithDottedModuleName` (xpkg-style names)
2 tasks
Sunrisepeak
added a commit
that referenced
this pull request
May 9, 2026
The v0.0.2 GitHub Release is being re-issued with the same version number to fold in three improvements that landed against main *after* the original tag was pushed: * fix(modgraph): partition import scanner no longer concatenates the unit's own `:partition` into imported names (PR #14) * feat: lib-root convention `src/<package-tail>.cppm` + optional `[lib].path` (PR #15) CHANGELOG's [0.0.2] entry is amended in place to capture them, since no v0.0.3 has been published yet and we're keeping the version number stable while the project is still pre-1.0. After this PR merges, the v0.0.2 git tag and GitHub Release will be re-pointed at the new HEAD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import :foofrom a partition-interface unit (export module M:bar;)was being resolved to
M:bar:foo— the scanner prependedprovides->logicalNameverbatim, which already contains the unit'sown
:barsuffix. GCC's dyndep step still resolves the importcorrectly (its own scan sees the right name), so builds succeed, but
mcpp prints
once for every such import. Reproduced under
mcpplibs/tinyhttps: sevenwarnings per build.
Fix
if (name.starts_with(":") && u.provides) { - name = u.provides->logicalName + name; + std::string base = u.provides->logicalName; + if (auto p = base.find(':'); p != std::string::npos) { + base.resize(p); + } + name = base + name; }So for
M:barimporting:foowe now produceM:foo(the sibling),not
M:bar:foo.Coverage
Three new tests in
test_modgraph.cpp:Scanner.PartitionImportFromPrimaryInterface— regression guardScanner.PartitionImportFromAnotherPartition— the bugScanner.PartitionImportWithDottedModuleName— xpkg-style namesVerification
mcpp test— 9/9 unit binaries pass (incl. 3 new cases)mcpp buildofmcpplibs/tinyhttps(which exercises the bugwith 7
import :partitionsites) is now warning-free