v
v copied to clipboard
constant value not accepted as array size if defined in const block with $if clause
Describe the bug
`import os
const ( buf_size = $if windows { os.max_path_len * 2 } $else { os.max_path_len } )
fn main() { mut buf := [buf_size]u8{} println(buf.len) } `
Expected Behavior
The array size (positive) dumped to screen
Current Behavior
`bug.v:9:17: error: fixed size cannot be zero or negative (fixed_size: 0)
9 | mut buf := [buf_size]u8{}
| ~~~~~~~~
Reproduction Steps
code example above
Possible Solution
Correctly handle constants declared in const block even when $if is used
Additional Information/Context
No response
V version
V 0.3.3 15cb18c
Environment details (OS name and version, etc.)
Windows 10 64 bit