aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-11-16 00:31:09 +0200
committerVeikka Tuominen <git@vexu.eu>2022-11-16 01:12:54 +0200
commitfe6249348f615c975a2db53bb0c93f83bd2a281b (patch)
treee059a560361900c2d6e0d226be20cebc9ea0c74e /test
parentfb09093d95f2dc9bf454ba0d1d489316311adffc (diff)
downloadzig-fe6249348f615c975a2db53bb0c93f83bd2a281b.tar.gz
zig-fe6249348f615c975a2db53bb0c93f83bd2a281b.zip
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
Diffstat (limited to 'test')
-rw-r--r--test/behavior/eval.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/eval.zig b/test/behavior/eval.zig
index cd0891990c..145be9dede 100644
--- a/test/behavior/eval.zig
+++ b/test/behavior/eval.zig
@@ -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);
+}