v
v copied to clipboard
$compile_error not work as expected
Describe the bug
$compile_error should work with $if.
Reproduction Steps
comp.v
module main
fn foo[T](val T) bool {
$if T is bool || T is $int {
return true
} $else {
$compile_error('only support bool or number type')
}
return false
}
fn main() {
_ := foo(123)
}
compile it:
v comp.v
Expected Behavior
compile ok
Current Behavior
$ v comp.v
comp.v:7:3: error: only support bool or number type
5 | return true
6 | } $else {
7 | $compile_error('only support bool or number type')
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 | }
9 | return false
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.10 6ca0976896d31148d3d88ca9c5a497dfdaf66110.21c54ce
Environment details (OS name and version, etc.)
| V full version | V 0.4.10 6ca0976896d31148d3d88ca9c5a497dfdaf66110.21c54ce |
|---|---|
| OS | linux, Ubuntu 24.04.2 LTS |
| Processor | 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz |
| Memory | 8.32GB/15.51GB |
| V executable | /media/HD/github/kbkpbot/v/v |
| V last modified time | 2025-05-23 13:33:33 |
| V home dir | OK, value: /media/HD/github/kbkpbot/v |
| VMODULES | OK, value: /home/mars/.vmodules |
| VTMP | OK, value: /tmp/v_1000 |
| Current working dir | OK, value: /home/mars/v/bug |
| Git version | git version 2.43.0 |
| V git status | weekly.2025.17-153-gb106a2a0-dirty |
| .git/config present | true |
| cc version | cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 |
| gcc version | gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 |
| clang version | Ubuntu clang version 18.1.3 (1ubuntu1) |
| tcc version | tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux) |
| tcc git status | thirdparty-linux-amd64 696c1d84 |
| emcc version | N/A |
| glibc version | ldd (Ubuntu GLIBC 2.39-0ubuntu8.4) 2.39 |
[!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.
Connected to Huly®: V_0.6-22928
fixed