24 lines
563 B
Plaintext
24 lines
563 B
Plaintext
// Issue: match on u8 value with enum result assigned to typed field
|
|
// The switch value is u8 but case constants are s64 (default int literal type).
|
|
// Compiler should cast case constants to match the switch value type.
|
|
// LLVM error: Switch constants must all be same type as switch value!
|
|
|
|
out :: (str: string) -> void #builtin;
|
|
|
|
Button :: enum {
|
|
none;
|
|
left;
|
|
middle;
|
|
right;
|
|
}
|
|
|
|
main :: () {
|
|
val : u8 = 2;
|
|
result : Button = if val == {
|
|
case 1: .left;
|
|
case 2: .middle;
|
|
case 3: .right;
|
|
else: .none;
|
|
};
|
|
}
|