structs as errors in fallibles

This commit is contained in:
2026-08-08 22:49:31 +02:00
parent e0f1d2d7cb
commit 729488e702
5 changed files with 80 additions and 5 deletions
+13
View File
@@ -4487,6 +4487,19 @@ ct_return_value :: proc(state: ^Ct_State, expr_id: ast.Expr_Id, span: source.Spa
if expr.kind == .Enum_Literal && types.sum_has_name(&checker.module.types, error_type, u32(expr.name)) {
error_path = true
expected = error_type
} else if expr.kind == .Struct_Literal {
target_pkg, available := expr_package(checker, expr, state.pkg, state.file, true)
named := types.find_named(
&checker.module.types,
u32(target_pkg),
u32(expr.name),
file=u32(expr_lookup_file(expr, state.file)),
) if available else types.INVALID
named = types.resolve_alias(named, &checker.module.types)
if can_implicitly_convert_type(checker, named, error_type) {
error_path = true
expected = error_type
}
} else if expr.kind == .Name && !symbol.is_valid(expr.qualifier) {
if index, found := ct_find_binding_index(state, expr.name); found {
actual := state.bindings[index].type