V version: V 0.1.27 48659f4.0de70e8
OS: Debian GNU/Linux 10 (buster):
What did you do?
import os
fn main() {
mkdir('foo')
}
fn mkdir(name string) {
os.mkdir(name) or {
panic(err)
}
}
What did you expect to see?
Successfully created directory.
What did you see instead?
/tmp/v/isolate.tmp.c: In function ‘os__mkdir’:
/tmp/v/isolate.tmp.c:9578:21: error: incompatible type for argument 1 of ‘mkdir’
int r = mkdir(apath.str, 511);
~~~~~^~~~
/tmp/v/isolate.tmp.c:1355:26: note: expected ‘string’ {aka ‘struct string’} but argument is of type ‘byteptr’ {aka ‘unsigned char *’}
static void mkdir(string name);
~~~~~~~^~~~
/tmp/v/isolate.tmp.c:9578:10: error: too many arguments to function ‘mkdir’
int r = mkdir(apath.str, 511);
^~~~~
/tmp/v/isolate.tmp.c:1355:13: note: declared here
static void mkdir(string name);
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error. This should never happen.
mkdir conflict with the function name in the libc library, it is recommended to change the function name.
Of course, the compiler still has some problems, this should be avoided.
@yuyi98 I see, thank you for the explanation.
I'm closing this for now, since the problem is most likely to be known to the devs.
Good catch :+1:
Not sure if the issue is really taken into account, so we'll keep it open until it's fixed :blush:
I am working on a patch to reintroduce main__ prefixing for main module functions. That will solve this issue, as well as others related to common C function name clashes.
Most helpful comment
I am working on a patch to reintroduce main__ prefixing for main module functions. That will solve this issue, as well as others related to common C function name clashes.