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.5k stars 2.15k forks source link

cgen error for `assert foption() == none` #21715

Closed spytheman closed 3 days ago

spytheman commented 6 days ago

V doctor:

V full version: V 0.4.6 c689f80.549e11b
OS: linux, Ubuntu 20.04.6 LTS
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz

getwd: /space/v/oo
vexe: /space/v/oo/v
vexe mtime: 2024-06-23 06:53:46

vroot: OK, value: /space/v/oo
VMODULES: OK, value: /home/delian/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.2
Git vroot status: weekly.2024.25-9-g549e11bf-dirty (2 commit(s) behind V master)
.git/config present: true

CC version: cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

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

fn find_token_by_id() ?int {
    return none
}

// This works:
// token := find_token_by_id()
// assert token == none

// This should work too:
assert find_token_by_id() == none
println('done')

What did you expect to see?

a compiled program

What did you see instead?

==================
/tmp/v_1000/a.01J11ZAXP67X127N8815H6T592.tmp.c:13156: error: '_t1' undeclared
...
==================
(Use `v -cg` to print the entire error message)

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.