This commit is contained in:
agra
2026-02-24 18:17:33 +02:00
parent 630e76c319
commit 7a381e1b4c
4 changed files with 90 additions and 2 deletions

25
examples/issue-0003.sx Normal file
View File

@@ -0,0 +1,25 @@
// 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;
};
}