26 lines
566 B
Plaintext
26 lines
566 B
Plaintext
// Issue: enum literal inference in match expression used as assignment RHS
|
|
// When a match expression is assigned to a field with a known enum type,
|
|
// the enum literals in case arms should infer their type from the assignment target.
|
|
|
|
Color :: enum {
|
|
red;
|
|
green;
|
|
blue;
|
|
none;
|
|
}
|
|
|
|
Thing :: struct {
|
|
color: Color;
|
|
}
|
|
|
|
main :: () {
|
|
t : Thing = ---;
|
|
value : u8 = 1;
|
|
t.color = if value == {
|
|
case 1: .red; // error: cannot infer enum type for literal
|
|
case 2: .green;
|
|
case 3: .blue;
|
|
else: .none;
|
|
};
|
|
}
|