fix(scanner): skip raw-string-literal bodies when detecting imports#138
Merged
Conversation
The default regex module scanner (scan_file in modgraph/scanner.cppm) scanned each line as raw text, stripping only line comments. A line whose trimmed text began with 'import' was treated as a real module import even when it lived inside a multi-line raw-string literal — e.g. the 'mcpp new --template gui' skeleton stored as R"GUI( ... import imgui.core; ... )GUI" in scaffold/create.cppm. That produced spurious 'module imgui.core imported but not provided in this build' warnings on every mcpp build. Track raw-string state across lines (strip_raw_strings) and blank out raw bodies before import/module matching. Ordinary "..." strings are left as is: the matcher only fires on lines that *start with* the keyword, which a string body can only do across lines (a raw string). Adds two regression tests; verified the real create.cppm no longer warns. Also lands the follow-ups design doc (.agents/docs/2026-06-22).
Sunrisepeak
added a commit
that referenced
this pull request
Jun 21, 2026
* fix(build): self-heal stale build.ninja on 'missing and no known rule' When a dependency package under the registry is reinstalled/moved but keeps the same version string, the build fingerprint (which does not yet cover registry dep state) is unchanged, so the cached build.ninja is reused. Ninja then aborts with 'missing and no known rule to make it' and the build hard-fails, forcing the user to run `mcpp clean` by hand. Add that signature to is_stale_ninja_failure so try_fast_build drops to a full graph regeneration (same invocation) instead of failing — the stale graph is rewritten against the current dep state and the build proceeds. (Folding registry dep state into the fingerprint to avoid the regen entirely is a larger follow-up; see .agents/docs/2026-06-22 §T-j.) * chore: bump version 0.0.57 -> 0.0.58 Release carrying the follow-up batch: scanner raw-string fix (#138), first-run progress (#139), toolchain effective-resolution (#140), doctor runtime-dep check (#141), and the build.ninja self-heal above.
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.
Problem
Every
mcpp buildprints:mcpp itself doesn't depend on imgui. The
import imgui.core;/import imgui.app;lines live inside a raw-string literal — the
mcpp new --template guiskeleton, stored as
R"GUI( ... )GUI"inscaffold/create.cppm:221-224.Root cause
The default regex scanner
scan_file(src/modgraph/scanner.cppm) scans eachline as raw text and strips only line comments. It has no lexical state for
string/raw-string literals, so a line whose trimmed text starts with
importis matched as a real import even inside a raw string. The warning is then
emitted by
resolve_graphand printed fromprepare.cppm.(The opt-in
MCPP_SCANNER=p1689compiler-driven path is not fooled; thedefault regex path is.)
Fix
Track raw-string state across lines (
strip_raw_strings) and blank out rawbodies before import/module matching. Ordinary
"..."strings are left as-is:the matcher only fires on lines that start with the keyword, which a string
body can only do when it spans lines (a raw string).
Tests
Scanner.IgnoresImportsInsideRawStringLiteral— multi-lineR"GUI(...)GUI"with embedded
import imgui.core;→ only the genuine top-level importsrecorded.
Scanner.IgnoresImportInsideSingleLineRawString.create.cppmno longer warns when built with the patchedbinary (
mcpp test: all green).The existing
Scanner.ProvidesAndRequirestest even carried a NOTE to avoidraw strings because of this false positive — now unnecessary.
First of 5 follow-up PRs; plan in
.agents/docs/2026-06-22-mcpp-followups-design.md.