Repository navigation
util: qualify modules relative to compilation project root (fix #27138) - #27219
Merged
Merged
Conversation
When a project has a subdirectory with its own `v.mod`, importing a submodule like `import dep.mymod` from the outer project failed with `unknown enum dep.mymod.Color (type_idx=0)` β the file was parsed but registered under the wrong qualified name (`mymod` instead of `dep.mymod`), because the inner `v.mod` was treated as the naming boundary. Anchor `mod_path_to_full_name` to the v.mod that contains `pref.path` so nested v.mod files no longer shrink module names.
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
Fixes #27138: when a project contains a subdirectory with its own
v.mod, importing a submodule likeimport dep.mymodfrom the outer project failed withunknown enum dep.mymod.Color (type_idx=0)andunknown function: dep.mymod.color_name. The dependency's.vfiles were parsed but registered under the wrong qualified name (mymodinstead ofdep.mymod), because the innerv.modwas treated as the naming boundary inutil.qualify_module.The fix anchors
mod_path_to_full_nameto the v.mod that contains the current compilation (pref.path). When the resolved module directory lies inside that project root, the module name is computed relative to it, so a nested v.mod no longer shrinks names of its sub-modules. The existing standalone case (`cd dep && v .`) is preserved β it's covered bytest_running_project_from_its_own_vmod_with_parent_vmod_works_issue_26828, which still passes.Test plan
red / mymod.Point{...} / ok, withdep/v.modpresent.dep/v.mod(no regression in the workaround path)../v -o v cmd/vruns cleanly for two iterations.vlib/v/tests/modules/β 19/19 pass (includessub/sub_test.vwhich uses a nestedv.modinside a submodule).vlib/v/tests/project_with_modules_having_submodules/β 2/2 pass.vlib/v/tests/projects_that_should_compile_test.vβ all pass, including newtest_importing_submodule_through_nested_vmod_works_issue_27138regression test.cmd/tools/vpm/β 13/13 pass.