disambiguate enum blocks and complete distinct type operations

This commit is contained in:
2026-08-01 23:57:35 +02:00
parent 91aa601464
commit b9526b5f06
34 changed files with 1128 additions and 1963359 deletions
+27 -3
View File
@@ -1106,9 +1106,33 @@ is_runtime_value :: proc(value: Type, store: ^Store, depth := 0) -> bool {
return false
}
can_construct_distinct :: proc(from, to: Type, store: ^Store) -> bool {
item, ok := node(store, to)
return ok && item.kind == .Distinct && item.declared && equal(from, item.child)
distinct_backing :: proc(value: Type, store: ^Store) -> (Type, bool) {
item, ok := node(store, value)
if !ok || item.kind != .Distinct || !item.declared {
return INVALID, false
}
return item.child, true
}
distinct_scalar_backing :: proc(value: Type, store: ^Store) -> (Type, bool) {
_, ok := distinct_backing(value, store)
if !ok {
return INVALID, false
}
backing := runtime_representation(value, store)
return backing, is_concrete_scalar(backing)
}
can_retype_distinct :: proc(from, to: Type, store: ^Store) -> bool {
if backing, ok := distinct_backing(to, store); ok && equal(from, backing) {
return true
}
backing, ok := distinct_backing(from, store)
if !ok || !equal(to, backing) {
return false
}
_, scalar := distinct_scalar_backing(from, store)
return scalar
}
runtime_representation :: proc(value: Type, store: ^Store, depth := 0) -> Type {