cgen: fix default value init for union sum types (#6795)
parent
a4acb70c64
commit
43ce098043
|
@ -5295,7 +5295,7 @@ fn (mut g Gen) type_default(typ_ table.Type) string {
|
||||||
else {}
|
else {}
|
||||||
}
|
}
|
||||||
return match sym.kind {
|
return match sym.kind {
|
||||||
.interface_, .sum_type, .array_fixed, .multi_return { '{0}' }
|
.interface_, .union_sum_type, .sum_type, .array_fixed, .multi_return { '{0}' }
|
||||||
.alias { g.type_default((sym.info as table.Alias).parent_type) }
|
.alias { g.type_default((sym.info as table.Alias).parent_type) }
|
||||||
else { '0' }
|
else { '0' }
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,6 +432,15 @@ fn test_match_multi_branch() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Outer2 {
|
||||||
|
e Expr4
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_zero_value_init() {
|
||||||
|
// no c compiler error then it's successful
|
||||||
|
o := Outer2{}
|
||||||
|
}
|
||||||
|
|
||||||
fn test_sum_type_match() {
|
fn test_sum_type_match() {
|
||||||
// TODO: Remove these casts
|
// TODO: Remove these casts
|
||||||
assert is_gt_simple('3', int(2))
|
assert is_gt_simple('3', int(2))
|
||||||
|
|
Loading…
Reference in New Issue