Sema: ensure comptime reference to function points to original decl

This prevents sema from creating new decls for the functions and
passing them to the backends as non-function decls.

Closes #12501
This commit is contained in:
Veikka Tuominen
2022-11-16 00:31:09 +02:00
parent fb09093d95
commit fe6249348f
2 changed files with 22 additions and 0 deletions

View File

@@ -1507,3 +1507,18 @@ test "inline call in @TypeOf inherits is_inline property" {
};
try expect(S.T == void);
}
test "comptime function turns function value to function pointer" {
const S = struct {
fn fnPtr(function: anytype) *const @TypeOf(function) {
return &function;
}
fn Nil() u8 {
return 0;
}
const foo = &[_]*const fn () u8{
fnPtr(Nil),
};
};
comptime try expect(S.foo[0] == &S.Nil);
}