add noreturn and unreachable
This commit is contained in:
@@ -45,6 +45,7 @@ FLOAT :: Type(30)
|
||||
RANGE :: Type(31)
|
||||
ANYOPAQUE :: Type(32)
|
||||
UINT :: Type(33)
|
||||
NORETURN :: Type(34)
|
||||
|
||||
DYNAMIC_START :: Type(64)
|
||||
|
||||
@@ -58,6 +59,7 @@ Numeric_Category :: enum u8 {
|
||||
Kind :: enum u8 {
|
||||
Invalid,
|
||||
Void,
|
||||
Noreturn,
|
||||
Anyopaque,
|
||||
Int_Constraint,
|
||||
Uint_Constraint,
|
||||
@@ -599,6 +601,8 @@ kind :: proc(value: Type, store: ^Store = nil) -> Kind {
|
||||
return .Invalid
|
||||
case VOID:
|
||||
return .Void
|
||||
case NORETURN:
|
||||
return .Noreturn
|
||||
case ANYOPAQUE:
|
||||
return .Anyopaque
|
||||
case INT:
|
||||
@@ -643,6 +647,10 @@ is_void :: proc(value: Type) -> bool {
|
||||
return value == VOID
|
||||
}
|
||||
|
||||
is_noreturn :: proc(value: Type) -> bool {
|
||||
return value == NORETURN
|
||||
}
|
||||
|
||||
is_anyopaque :: proc(value: Type) -> bool {
|
||||
return value == ANYOPAQUE
|
||||
}
|
||||
@@ -1717,6 +1725,12 @@ can_coerce_c_scalar :: proc(from, to: Type, selected := target.DEFAULT) -> bool
|
||||
}
|
||||
|
||||
widest :: proc(a, b: Type) -> Type {
|
||||
if is_noreturn(a) {
|
||||
return b
|
||||
}
|
||||
if is_noreturn(b) {
|
||||
return a
|
||||
}
|
||||
if equal(a, b) && is_concrete_scalar(a) {
|
||||
return a
|
||||
}
|
||||
@@ -1759,6 +1773,7 @@ name :: proc(value: Type) -> string {
|
||||
switch value {
|
||||
case INVALID: return "<invalid>"
|
||||
case VOID: return "void"
|
||||
case NORETURN: return "noreturn"
|
||||
case ANYOPAQUE: return "anyopaque"
|
||||
case BOOL: return "bool"
|
||||
case INT: return "int"
|
||||
|
||||
Reference in New Issue
Block a user