structs as errors in fallibles
This commit is contained in:
@@ -3976,19 +3976,20 @@ validate_declarations :: proc(checker: ^Checker) {
|
||||
}
|
||||
if types.is_valid(function.error) && !signature_poisoned {
|
||||
error_type := type_from_syntax(checker, function.error, function.pkg, function.file)
|
||||
error_sum := types.is_enum(error_type, &checker.module.types) ||
|
||||
types.is_tagged_union(error_type, &checker.module.types)
|
||||
error_channel := types.is_enum(error_type, &checker.module.types) ||
|
||||
types.is_struct(error_type, &checker.module.types) ||
|
||||
types.is_tagged_union(error_type, &checker.module.types)
|
||||
if function.c_abi {
|
||||
checker.template_diagnostics[function_id] = source.add(
|
||||
checker.diagnostics,
|
||||
function.span,
|
||||
"fallible functions must use 'func', not 'c_func'",
|
||||
)
|
||||
} else if !error_sum {
|
||||
} else if !error_channel {
|
||||
checker.template_diagnostics[function_id] = source.add(
|
||||
checker.diagnostics,
|
||||
function.span,
|
||||
"fallible function error type must be a native enum or tagged union",
|
||||
"fallible function error type must be a native enum, struct, or tagged union",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user