checker: take into count the recursive sum type with in alias
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>pull/13974/head
parent
68c5699c1f
commit
93856f82c6
|
|
@ -1320,7 +1320,10 @@ fn (t &Table) sumtype_check_alias_variant(parent_type Type, alias_type Type, is_
|
|||
// the alias is not inside one of the Sum type, like
|
||||
// https://github.com/vlang/v/issues/13863
|
||||
alias_info := t.sym(alias_type).info as Alias
|
||||
return t.sumtype_has_variant(parent_type, alias_info.parent_type, is_as)
|
||||
// The alias is an alias or of the same type of the parent or one
|
||||
// of the SumType variant. e.g: alias of another sum type
|
||||
return parent_type == alias_info.parent_type
|
||||
|| t.sumtype_has_variant(parent_type, alias_info.parent_type, is_as)
|
||||
}
|
||||
// the alias_type is inside one of the variant of the sum type
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
struct Empty {}
|
||||
|
||||
type IndexNumber = u32
|
||||
type NameIndexType = Empty | IndexNumber
|
||||
|
||||
fn main() {
|
||||
fn test_casting_with_sumtype_and_alias() {
|
||||
elem := NameIndexType(Empty{})
|
||||
if elem is IndexNumber {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue