error handling kickoff
This commit is contained in:
@@ -200,7 +200,7 @@ translate_c_type :: proc(
|
||||
}
|
||||
|
||||
function_signatures_equal :: proc(left: ast.Function, params: []ast.Param, result: types.Type, variadic: bool) -> bool {
|
||||
if left.result != result || left.variadic != variadic || len(left.params) != len(params) {
|
||||
if left.result != result || types.is_valid(left.error) || left.variadic != variadic || len(left.params) != len(params) {
|
||||
return false
|
||||
}
|
||||
for param, index in params {
|
||||
@@ -1333,12 +1333,20 @@ canonical_type :: proc(
|
||||
}
|
||||
if item.kind == .Struct || item.kind == .Union {
|
||||
mapping[index] = value
|
||||
module.type_store.nodes[index].extra = canonical_type(module, item.extra, mapping, visiting)
|
||||
fields := types.fields_for(&module.type_store, value)
|
||||
for &field in fields {
|
||||
field.type = canonical_type(module, field.type, mapping, visiting)
|
||||
}
|
||||
return value
|
||||
}
|
||||
if item.kind == .Fallible {
|
||||
item.child = canonical_type(module, item.child, mapping, visiting)
|
||||
item.extra = canonical_type(module, item.extra, mapping, visiting)
|
||||
resolved := types.fallible(&module.type_store, item.child, item.extra)
|
||||
mapping[index] = resolved
|
||||
return resolved
|
||||
}
|
||||
if item.kind == .Function {
|
||||
params := make([]types.Type, int(item.field_count), context.temp_allocator)
|
||||
for param, param_index in types.params_for(&module.type_store, value) {
|
||||
@@ -1352,6 +1360,9 @@ canonical_type :: proc(
|
||||
if types.is_valid(item.child) {
|
||||
item.child = canonical_type(module, item.child, mapping, visiting)
|
||||
}
|
||||
if types.is_valid(item.extra) {
|
||||
item.extra = canonical_type(module, item.extra, mapping, visiting)
|
||||
}
|
||||
resolved := types.intern(&module.type_store, item)
|
||||
mapping[index] = resolved
|
||||
return resolved
|
||||
@@ -1368,6 +1379,7 @@ canonicalize_types :: proc(module: ^ast.Module, allocator: mem.Allocator) {
|
||||
param.type = canonical_type(module, param.type, mapping, visiting)
|
||||
}
|
||||
function.result = canonical_type(module, function.result, mapping, visiting)
|
||||
function.error = canonical_type(module, function.error, mapping, visiting)
|
||||
}
|
||||
for &global in module.globals {
|
||||
global.type = canonical_type(module, global.type, mapping, visiting)
|
||||
@@ -1378,6 +1390,9 @@ canonicalize_types :: proc(module: ^ast.Module, allocator: mem.Allocator) {
|
||||
for index := 0; index < original_count; index += 1 {
|
||||
_ = canonical_type(module, types.DYNAMIC_START+types.Type(index), mapping, visiting)
|
||||
}
|
||||
for &variant in module.type_store.variants {
|
||||
variant.payload = canonical_type(module, variant.payload, mapping, visiting)
|
||||
}
|
||||
}
|
||||
|
||||
load :: proc(
|
||||
|
||||
Reference in New Issue
Block a user