You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you explicitly reference enum values as match cases you will get a C error error: duplicate case value once you exceed 4 cases with an else or you will receive error: match must be exhaustive without an else even if your cases are exhaustive.
Note this works properly if you use the shortcut .enum_value notation, but I didn't realize that existed until I ran into this.
Reproduction Steps
pub enum TokenType {
null
word
get_word
set_word
lit_word
int_value
dec_value
bin_value
str_value
block_start
block_end
expr_start
expr_end
comment
}
t := TokenType.word
s := match t {
(TokenType.null) { "" }
(TokenType.word) { "a" }
(TokenType.get_word) { "b" }
(TokenType.set_word) { "c" }
(TokenType.lit_word) { "d" }
else { "other" }
}
println(s)
Expected Behavior
Should simply print "a", and it will if you remove the case (TokenType.lit_word) { "d" }
Current Behavior
On V playground:
Running code...
Can't run code. The server returned an error:
/box/code.v:27: error: duplicate case value
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
Exited with error status 1
Please try again.
Possible Solution
These examples work properly:
t := TokenType.word
s := match t {
(TokenType.null) { "" }
(TokenType.word) { "a" }
(TokenType.get_word) { "b" }
(TokenType.set_word) { "c" }
else { "other" }
}
println(s)
t := TokenType.word
s := match t {
.null { "" }
.word { "a" }
.get_word { "b" }
.set_word { "c" }
.lit_word { "d" }
else { "other" }
}
println(s)
Additional Information/Context
V version
0.4.12
Environment details (OS name and version, etc.)
|V full version |V 0.4.12 55436caa9ae9c179639a4b238fc358ee7d768645
|:-------------------|:-------------------
|OS |windows, Microsoft Windows 11 Pro 26200 64-bit
|Processor |28 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i7-13850HX
|Memory |16.39GB/31.61GB
| |
|V executable |C:\Program Files\v_windows\v\v.exe
|V last modified time|2025-12-06 21:31:43
| |
|V home dir |contains spaces, value: C:\Program Files\v_windows\v
|VMODULES |contains spaces, value: C:\Users\Casey Duncan\.vmodules
|VTMP |contains spaces, value: C:\Users\Casey Duncan\AppData\Local\Temp\v_0
|Current working dir |contains spaces, value: C:\Users\Casey Duncan\projects\vebol
| |
|Git version |git version 2.52.0.windows.1
|V git status |N/A
|.git/config present |false
| |
|cc version |N/A
|gcc version |N/A
|clang version |N/A
|msvc version |N/A
|tcc version |tcc version 0.9.27 (x86_64 Windows)
|tcc git status |N/A
|emcc version |N/A
|glibc version |ldd (cygwin) 3.6.5
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.
Describe the bug
If you explicitly reference enum values as match cases you will get a C error
error: duplicate case valueonce you exceed 4 cases with anelseor you will receiveerror: match must be exhaustivewithout an else even if your cases are exhaustive.Note this works properly if you use the shortcut
.enum_valuenotation, but I didn't realize that existed until I ran into this.Reproduction Steps
Expected Behavior
Should simply print
"a", and it will if you remove the case(TokenType.lit_word) { "d" }Current Behavior
On V playground:
Possible Solution
These examples work properly:
Additional Information/Context
V version
0.4.12
Environment details (OS name and version, etc.)
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.