Skip to content

Commit

Permalink
v.builder: fix compiling code, that imports modules from both `src/mo…
Browse files Browse the repository at this point in the history
…dules` and `modules` (#19437)
  • Loading branch information
nemoola committed Sep 25, 2023
1 parent e7aa6a1 commit 07bd94f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion vlib/v/builder/compile.v
Expand Up @@ -214,11 +214,14 @@ pub fn (mut v Builder) set_module_lookup_paths() {
if v.pref.is_verbose {
println('x: "${x}"')
}

if os.exists(os.join_path(v.compiled_dir, 'src/modules')) {
v.module_search_paths << os.join_path(v.compiled_dir, 'src/modules')
} else {
}
if os.exists(os.join_path(v.compiled_dir, 'modules')) {
v.module_search_paths << os.join_path(v.compiled_dir, 'modules')
}

v.module_search_paths << v.pref.lookup_path
if v.pref.is_verbose {
v.log('v.module_search_paths:')
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/tests/projects_that_should_compile_test.v
Expand Up @@ -27,5 +27,5 @@ fn test_projects_should_run() {
assert res.trim_space() == 'v0'

res2 := vrun_ok('run', vroot_path('vlib/v/tests/testdata/modules_in_src/'))
assert res2.trim_space() == 'somemodule'
assert res2.trim_space() == 'somemodule somemoduletwo'
}
@@ -0,0 +1,7 @@
module somemoduletwo

const name = 'somemoduletwo'

pub fn name() string {
return somemoduletwo.name
}
3 changes: 2 additions & 1 deletion vlib/v/tests/testdata/modules_in_src/src/main.v
@@ -1,7 +1,8 @@
module main

import somemodule
import somemoduletwo

fn main() {
println(somemodule.name())
println('${somemodule.name()} ${somemoduletwo.name()}')
}

0 comments on commit 07bd94f

Please sign in to comment.