Compiler fails in submodule definitions
Describe the bug
The V compiler shows and error message in a simple sub-module definition, depends on the path of the main source file is absolute or relative.
Reproduction Steps
In this example project
├── my_math
│ ├── floating.v
│ └── my_integer
│ └── integer.v
├── README.md
└── running_my_math.v
if you try to compile it as:
v run running_my_math.v
v run ./running_my_math.v
or
v run .
the compiler throws this error:
Did you mean `my_math.addition`?
10 | println('La suma de a y b es ${my_math.addition(a, b)}')
11 |
12 | println('La suma entera de a y b es ${my_integer.addition(a, b)}')
| ~~~~~~~~~~~~~~
13 | }
running_my_math.v:12:51: error: expression does not return a value
10 | println('La suma de a y b es ${my_math.addition(a, b)}')
11 |
12 | println('La suma entera de a y b es ${my_integer.addition(a, b)}')
| ~~~~~~~~~~~~~~
13 | }
like if it does not recognize the files in the submodule my_integer.
But if you call the compiler with the absolute path of the main source file like this:
v run "/home/user/Tests/Vlang_tests/submodules_in_Vlang/running_my_math.v"
the project is compiled well:
La suma de a y b es 47.7
La suma entera de a y b es 47
Expected Behavior
That the compiler accepts a relative main source path in projects which includes submodules.
Current Behavior
The compiler only accepts an absolute main source path in projects which includes submodules.
Possible Solution
No idea.
Additional Information/Context
Example project repository: https://github.com/fermarsan/submodules_in_Vlang.git
V version
0.4.10
Environment details (OS name and version, etc.)
Linux Mint Debian Edition 6 (LMDE 6)
[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.
Connected to Huly®: V_0.6-23008
I've just added empty v.mod in project's root and its worked:
@ctkjose, I think this is one of the issues you are trying to address in https://github.com/vlang/v/discussions/24569 ?
gechandesu you are right, that solve the problem temporally, thank you.