struct field declared type inference
This commit is contained in:
@@ -4744,12 +4744,15 @@ infer_compound_expr :: proc(
|
||||
if ok && item_ok {
|
||||
initialized[slot-int(item.field_start)] = true
|
||||
}
|
||||
if !ok || !is_inferred_record_field(checker, slot) {
|
||||
if !ok {
|
||||
_ = infer_nested_expr(checker, keyed_expr.left, locals, pkg, file, demanded, local_types)
|
||||
continue
|
||||
}
|
||||
field_expected := field.type if is_runtime_type(checker, field.type) else types.INVALID
|
||||
actual := infer_nested_expr(checker, keyed_expr.left, locals, pkg, file, demanded, local_types, field_expected)
|
||||
if !is_inferred_record_field(checker, slot) {
|
||||
continue
|
||||
}
|
||||
_ = record_field_expr_candidate(checker, slot, keyed_expr.left, actual, locals, pkg, file)
|
||||
if is_runtime_type(checker, checker.module.types.fields[slot].type) {
|
||||
_ = record_demand(
|
||||
|
||||
@@ -12,6 +12,13 @@ State :: struct {
|
||||
|
||||
arrlist_test std.ArrayList(Token) = arraylist.init(mem.c_allocator)
|
||||
|
||||
init func(allocator mem.Allocator) State {
|
||||
return State {
|
||||
tokens = arraylist.init(allocator),
|
||||
diagnostics = arraylist.init(allocator),
|
||||
}
|
||||
}
|
||||
|
||||
hide fail_alloc func(_ ?@mut anyopaque, _ usize, _ usize) ?*mut u8 {
|
||||
return none
|
||||
}
|
||||
@@ -34,6 +41,9 @@ hide fail_allocator mem.Allocator :: mem.Allocator {
|
||||
}
|
||||
|
||||
run func() i32 ! mem.AllocError {
|
||||
state State :: init(mem.c_allocator)
|
||||
_ = state
|
||||
|
||||
values std.ArrayList(i32) = arraylist.init(mem.c_allocator)
|
||||
defer arraylist.deinit(&values)
|
||||
if (values.items.len != 0 or values.capacity != 0) return 1
|
||||
|
||||
Reference in New Issue
Block a user