v
v copied to clipboard
[Compiler Bug] `option`
Describe the bug
module main
fn my_func(value int ) ?int {
mut result := 122
if value == 1 {
result = my_func(0) // compiler bug
//result = my_func(0) or { 123 } // ok
}
return result
}
fn main() {
println(my_func(0))
}
Expected Behavior
human readable error
Current Behavior
==================
C:/Users/russo/AppData/Local/Temp/v_0/optionalbug.9395584676589867429.tmp.c:7610: warning: cast between pointer and integer of different size
C:/Users/russo/AppData/Local/Temp/v_0/optionalbug.9395584676589867429.tmp.c:12615: error: cannot convert 'struct _option_int' to 'int'
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error. This should never happen.
This is a compiler bug, please report it using `v bug file.v`.
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
Reproduction Steps
v run optionalbug.v
V version
V 0.3.3 d00237f
Environment details (OS name and version, etc.)
V full version: V 0.3.3 b2a71ec.d00237f OS: windows, Microsoft Windows 10 Pro v19042 64-bit Processor: 16 cpus, 64bit, little endian,
getwd: C:\Users\russo\Desktop vexe: D:_dev\v_lang\v.exe vexe mtime: 2023-03-13 12:13:29
vroot: OK, value: D:_dev\v_lang VMODULES: OK, value: C:\Users\russo.vmodules VTMP: OK, value: C:\Users\russo\AppData\Local\Temp\v_0
Git version: git version 2.35.3.windows.1 Git vroot status: weekly.2023.10-44-gd00237f0 .git/config present: true
CC version: Error: exec failed (CreateProcess) with code 2: Не удается найти указанный файл. cmd: cc --version thirdparty/tcc status: thirdparty-windows-amd64 e90c2620