fix self reference through fn ptr field crash

closes #1208
This commit is contained in:
Andrew Kelley 2018-09-25 10:45:11 -04:00
parent 0e6c18c820
commit eafb8e8572
No known key found for this signature in database
GPG Key ID: 4E7CD66038A4D47C
2 changed files with 16 additions and 1 deletions

View File

@ -1184,7 +1184,7 @@ ZigType *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
gen_param_info->src_index = i;
gen_param_info->gen_index = SIZE_MAX;
if ((err = ensure_complete_type(g, type_entry)))
if ((err = type_resolve(g, type_entry, ResolveStatusZeroBitsKnown)))
return g->builtin_types.entry_invalid;
if (is_c_abi)

View File

@ -699,3 +699,18 @@ test "equality compare fn ptrs" {
var a = emptyFn;
assert(a == a);
}
test "self reference through fn ptr field" {
const S = struct {
const A = struct {
f: fn (A) u8,
};
fn foo(a: A) u8 {
return 12;
}
};
var a: S.A = undefined;
a.f = S.foo;
assert(a.f(a) == 12);
}