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
when declare a enum as i64, and set the enum value less than a 32bit value, it will not work in a map key.
Reproduction Steps
bug.v
modulemainenumBigasi64 {
// a = 4294967299 // change to a big value large than 32bit, will not fire the bug.a=1
b
}
fnmain() {
mutm:=map[Big]string{}
m[.a] ='a'
m[.b] ='b'if m[.a] =='a' {
println('ok')
}
}
v run bug.v
Expected Behavior
output
ok
Current Behavior
output nothing.
Possible Solution
V compiler use a builtin__map_hash_int_8 or builtin__map_hash_int_4 to handle 64bit or 32bit map key statically , but the underlying C compiler will decide to use 64bit or 32bit based on the enum value.
So it need to fix the enum value selection when use as a map key in cgen.
Describe the bug
when declare a enum as i64, and set the enum value less than a 32bit value, it will not work in a map key.
Reproduction Steps
bug.v
Expected Behavior
output
Current Behavior
output nothing.
Possible Solution
V compiler use a
builtin__map_hash_int_8orbuiltin__map_hash_int_4to handle 64bit or 32bit map key statically , but the underlying C compiler will decide to use 64bit or 32bit based on the enum value.So it need to fix the enum value selection when use as a map key in
cgen.Additional Information/Context
bug found by PR #25236
V version
V 0.4.11 a8d200a
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.