v icon indicating copy to clipboard operation
v copied to clipboard

modules are broken

Open Bowero opened this issue 7 years ago • 2 comments

V version: V 0.1.18 (latest commit: https://github.com/vlang/v/commit/ad32a3770bfee9ee5ffe9152a80e49bbb94d41d4) OS: Arch Linux

Description Modules are currently not working. When I try to create the example module, this fails:

// mymodule.v
module mymodule

// To export a function we have to use `pub`
pub fn say_hi() {
	println('hello from mymodule!')
}

I am compiling this with v -lib ./mymodule

It will give an error of this kind:

/home/bowero/Documents/mymodule/mymodule.v:4:14: redefinition of `mymodule.say_hi`

This seems to happen with every module and even empty modules will give an error.

panic: function `main` is undeclared in the main module

Bowero avatar Aug 25 '19 08:08 Bowero

Thanks to the efforts of @Henrixounez, the problem has been found.

The v -lib ./mymodule structure has been abandoned for v build module ./mymodule/. The / at the end of the command is very important.

This will work:

  • v build module ./mymodule/
  • v build module mymodule/

This will not work:

  • v build module ./mymodule
  • v build module mymodule

Bowero avatar Aug 25 '19 09:08 Bowero

I've updated the docs.

Will fix the slash issue.

medvednikov avatar Aug 25 '19 18:08 medvednikov