Comments (13)
The path to the compiled project also matters (whether it is relative or absolute):
#0 20:03:06 ᛋ master /v/oo❱./v examples/submodule/main.v
examples/submodule/main.v:1:1: builder error: bad module definition: examples/submodule/v imports module "mymodules" but /space/v/oo/examples/submodule/mymodules/main_functions.v is defined as module `mymodule`
1 | import mymodules { add_xy }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | import mymodules.submodule { sub_xy }
3 |
#1 20:03:12 ᛋ master /v/oo❱
#1 20:03:13 ᛋ master /v/oo❱./v /space/v/oo/examples/submodule/main.v
#0 20:03:17 ᛋ master /v/oo❱
from v.
For me it is:
main.v:1:1: builder error: bad module definition: v imports module "mymodules" but /home/felipe/github/v/examples/submodule/mymodules/main_functions.v is defined as module `mymodule`
1 | import mymodules { add_xy }
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | import mymodules.submodule { sub_xy }
3 |
from v.
For me it is:
main.v:1:1: builder error: bad module definition: v imports module "mymodules" but /home/felipe/github/v/examples/submodule/mymodules/main_functions.v is defined as module `mymodule` 1 | import mymodules { add_xy } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | import mymodules.submodule { sub_xy } 3 |
Try changing mymodules
to mymodule
.. I guess the latter is the module name.
from v.
No, the fix for @felipensp 's problem is to change the module
line at the top of mymodules/main_function.v
to module mymodules
instead of the current module mymodule
(which doesn't match the subdir name, so is patently incorrect).
For @weezy20 it looks like the original example was modified, as that's not the way it looks in the repo.
from v.
No, the fix for @felipensp 's problem is to change the
module
line at the top ofmymodules/main_function.v
tomodule mymodules
instead of the currentmodule mymodule
(which doesn't match the subdir name, so is patently incorrect).For @weezy20 it looks like the original example was modified, as that's not the way it looks in the repo.
I believe something was modified to make the example run (I don't know v) when I ran and copied the stderr. But in any case, isn't expected behaviour that this runs out of the box without any modifications? That's what I'm reporting in essence.
from v.
Yes, that is the expected behavior. It definitely needs a fix.
Locally, you can try one fix by editing examples/submodule/mymodules/main_function.v
and adding an s
to the end of the first line, so that it says module mymodules
.
That will fix what @felipensp reported.
Then try git restore main.v
in the examples/submodule
directory. That will hopefully fix what you're seeing, as well, so it should all work as expected.
We will have to get a PR in to fix the import in main_function.v.
from v.
changed module mymodule
-> module mymodules
in file mymodules/main_function.v
Yet I get this result when running single file
via vs-code. strangely, I cannot run this code still using v run main.v
however, if I use the absolute path, I don't get this error, and the code runs fine.
from v.
Might be just speculation but is it possible this has something to do with the os.real_path
function defined in os.j.v
which uses realPathSync
node API ? I just had someone tell me that they've experienced a similar issue i.e. module resolution failure in javascript when using nodejs on relative paths vs absolute path.
from v.
os.js.v
will only be used if you tell V to output JavaScript.
from v.
(This message was translated, Sorry for any English mistakes)
For me, it worked when I replaced 'mymodules' -> 'mymodule'.
|-- main.v
|-- mymodule
| |-- main_functions.v
| `-- submodule
| `-- sub_functions.v
`-- v.mod
main.v
import mymodule { add_xy }
import mymodule.submodule { sub_xy }
main_functions.v
module mymodule
$ v run main.v
5
3
I got curious because I tested with other letters and numbers, and they all worked, except for the letter ‘s’.
from v.
That's... really odd. The trailing s
shouldn't make any difference at all.
from v.
Reason is that the modules
path is searched for local modules if we come across it. We are just a little bit too loose when checking the path.
from v.
On this PR: #21083, using both a relative and an absolute path works correctly.
from v.
Related Issues (20)
- C codegen for struct with function member has gcc generating warnings HOT 4
- -dump-c-flags does not respect -o option HOT 7
- Add input_character_immediate() function to Stdlib
- Build error - undeclared varaible HOT 6
- v -prod for iui throws error HOT 1
- mut and & confusion HOT 4
- Compiler build error: cannot convert 'struct main__Object' to 'struct main__Object * HOT 3
- cgen error for program compiled with -autofree
- Array in closure not updated HOT 1
- Windows: coroutines should display a message that they don't work on Windows, instead of complaining about photonwrapper.so not found HOT 1
- error using `@[flag]` in `vlib/flag/flag.v`
- cgen error, when example is compiled with -autofree HOT 1
- [builder error] match + &
- Unhandled Exception 0xC0000005 HOT 1
- i tried the compile simple sdl window file from sdl example, it shows this error HOT 3
- cgen error: '__v_error' undeclared HOT 1
- anonymous struct embedding lacks checks
- How to obtain generic results using the following function? HOT 2
- string interpolation does not correctly reports pointer when used with maps
- carray_to_varray inside unsafe block warns about requiring an unsafe block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.