v
v copied to clipboard
Can't use enum type in generic embedded struct
Describe the bug
When I embed a generic struct and use an enum as the type I get compiler errors. This happens with and without a type hint for the enum as u8
Using an enum as generic type on a member variable does compile:
struct MyStruct {
my_template MyTemplate[MyEnum]
}
Expected Behavior
The program should be able to compile
Current Behavior
I get the following compiler errors:
C:/Users/Deluze/AppData/Local/Temp/v_0/test.6228793185062886984.tmp.c:496: warning: WINVER redefined
C:/Users/Deluze/AppData/Local/Temp/v_0/test.6228793185062886984.tmp.c:1233: error: ',' expected (got "]")
Using msvc I get:
test.657243120955787311.tmp.c
C:\Users\Deluze\AppData\Local\Temp\v_0\test.657243120955787311.tmp.c(1197): error C2143: syntax error: missing ';' before ']'
C:\Users\Deluze\AppData\Local\Temp\v_0\test.657243120955787311.tmp.c(1197): error C2059: syntax error: ']'
C:\Users\Deluze\AppData\Local\Temp\v_0\test.657243120955787311.tmp.c(1198): error C2059: syntax error: '}'
Reproduction Steps
module main
struct MyTemplate[T] {
data T
}
enum MyEnum as u8 {
client
server
}
struct MyStructure {
MyTemplate[MyEnum]
}
Possible Solution
No response
Additional Information/Context
No work arounds AFAIK
V version
V 0.3.3 968b519
Environment details (OS name and version, etc.)
V full version: V 0.3.3 2df23a6.968b519
OS: windows, Microsoft Windows 11 Home v22621 64-bit
Processor: 8 cpus, 64bit, little endian,
getwd: C:\Users\Deluze\projects\v-projects
vexe: C:\v\v.exe
vexe mtime: 2023-03-20 21:59:47
vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\Deluze\.vmodules
VTMP: OK, value: C:\Users\Deluze\AppData\Local\Temp\v_0
Git version: git version 2.29.2.windows.2
Git vroot status: weekly.2023.12-5-g968b519b
.git/config present: true
CC version: Error: exec failed (CreateProcess) with code 2: The system cannot find the file specified.
cmd: cc --version
thirdparty/tcc status: thirdparty-windows-amd64 e90c2620