V version: master e577b4074314c30bc967c5e03d1f3bc877d18339
OS: macOS
What did you do?
module main
fn u64(a int) {
println(a)
}
fn int(a int) {
println(a)
}
fn main() {
x := 1
u64(x)
int(x)
}
What did you expect to see?
To get an error that function name is incorrect or that name is reserved. Or as Golang or Rust does just call the function.
What did you see instead?
Currently it casts to given type and ignores that there is a function
@Rhymond it would necessary change each method from f64() to to_f64(). A check i've done for var names would be enough also in this case @medvednikov what do you think about?
Just need to make it work like Go and Rust.
Do the function check first, cast check later.
Or we can prohibit this, but it can slow down the parser a bit.
@medvednikov imo we shouldn't touch it, probably it would be a useless check
As my PR is closed so I think it will be better to close this issue and have the same behavior like Rust and Go has as @medvednikov said.
At this moment (V 0.1.27 33a9822) compilation signals the error, but it is in the C phase:
C:\Users\CVO\AppData\Local\Temp\v\test.tmp.c:1170:13: error: 'u64' redeclared as different kind of symbol
static void u64(int a);
^~~
C:\Users\CVO\AppData\Local\Temp\v\test.tmp.c:78:18: note: previous declaration of 'u64' was here
typedef uint64_t u64;
^~~
C:\Users\CVO\AppData\Local\Temp\v\test.tmp.c: In function '_STR':
C:\Users\CVO\AppData\Local\Temp\v\test.tmp.c:1293:14: warning: pointer targets in passing argument 1 of 'tos2' differ in signedness [-Wpointer-sign]
return tos2(buf);
^~~
C:\Users\CVO\AppData\Local\Temp\v\test.tmp.c:1049:8: note: expected 'byteptr' {aka 'unsigned char *'} but argument is of type 'char *'
...
Im pretty sure I have a good way to handle this
@joe-conigliaro What is it?
Most helpful comment
Just need to make it work like Go and Rust.
Do the function check first, cast check later.
Or we can prohibit this, but it can slow down the parser a bit.