From f66b5954c255233ce83209a9e91bb0e03c8cf812 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sun, 24 Mar 2024 19:22:16 +0100 Subject: [PATCH] v.utils: fix module lookup if module import parts end with the word `modules` (#21083) --- .github/workflows/linux_ci.yml | 2 ++ examples/submodule/mymodules/main_functions.v | 2 +- vlib/v/util/module.v | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux_ci.yml b/.github/workflows/linux_ci.yml index c6e6520893..ba0dfb93af 100644 --- a/.github/workflows/linux_ci.yml +++ b/.github/workflows/linux_ci.yml @@ -57,6 +57,8 @@ jobs: # run: V_CI_CSTRICT=1 ./v -cstrict test-self - name: 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 run: ./v -W build-tools - name: Build v binaries diff --git a/examples/submodule/mymodules/main_functions.v b/examples/submodule/mymodules/main_functions.v index 0697d36d25..71f058050c 100644 --- a/examples/submodule/mymodules/main_functions.v +++ b/examples/submodule/mymodules/main_functions.v @@ -1,4 +1,4 @@ -module mymodule +module mymodules pub fn add_xy(x int, y int) int { return x + y diff --git a/vlib/v/util/module.v b/vlib/v/util/module.v index bc676d5a74..b789a6f26a 100644 --- a/vlib/v/util/module.v +++ b/vlib/v/util/module.v @@ -107,8 +107,9 @@ fn mod_path_to_full_name(pref_ &pref.Preferences, mod string, path string) !stri } } mut in_vmod_path := false + parts := path.split(os.path_separator) for vmod_folder in vmod_folders { - if path.contains(vmod_folder + os.path_separator) { + if vmod_folder in parts { in_vmod_path = true break }