vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.79k stars 2.16k forks source link

shadowing function declarations with variables shouldn't be allowed #22685

Open zeozeozeo opened 2 hours ago

zeozeozeo commented 2 hours ago

V doctor:

V full version: V 0.4.8 5c65e58.7bd2bef
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 10 cpus, 64bit, little endian, 

getwd: C:\Users\user\Downloads
vexe: C:\Users\user\Desktop\Code\v\v.exe
vexe mtime: 2024-10-28 18:11:20

vroot: OK, value: C:\Users\user\Desktop\Code\v
VMODULES: OK, value: C:\Users\user\.vmodules
VTMP: OK, value: C:\Users\user\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.1
Git vroot status: weekly.2024.43-56-g7bd2bef1
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

What did you do? ./v -g -o vdbg cmd/v && ./vdbg test.v

fn x() {}

fn main() {
    x := 5
    println(x)
}

What did you expect to see?

An error message about x being redefined

What did you see instead?

5
enghitalo commented 2 hours ago

I don't know what the best solution is, but the less ambiguity allowed, the better.

medvednikov commented 1 hour ago

V has a check specifically for x := x

That's what's going on here.