v.utils: fix module lookup if module import parts end with the word modules (#21083)

This commit is contained in:
Turiiya 2024-03-24 19:22:16 +01:00 committed by GitHub
parent cf9746da5a
commit f66b5954c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View file

@ -57,6 +57,8 @@ jobs:
# run: V_CI_CSTRICT=1 ./v -cstrict test-self # run: V_CI_CSTRICT=1 ./v -cstrict test-self
- name: Build examples - name: Build examples
run: ./v -W build-examples run: ./v -W build-examples
- name: Run the submodule example, using a relative path
run: ./v -W run examples/submodule
- name: Build v tools - name: Build v tools
run: ./v -W build-tools run: ./v -W build-tools
- name: Build v binaries - name: Build v binaries

View file

@ -1,4 +1,4 @@
module mymodule module mymodules
pub fn add_xy(x int, y int) int { pub fn add_xy(x int, y int) int {
return x + y return x + y

View file

@ -107,8 +107,9 @@ fn mod_path_to_full_name(pref_ &pref.Preferences, mod string, path string) !stri
} }
} }
mut in_vmod_path := false mut in_vmod_path := false
parts := path.split(os.path_separator)
for vmod_folder in vmod_folders { for vmod_folder in vmod_folders {
if path.contains(vmod_folder + os.path_separator) { if vmod_folder in parts {
in_vmod_path = true in_vmod_path = true
break break
} }