aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2023-09-16 00:10:42 +0100
committerAndrew Kelley <andrew@ziglang.org>2023-09-15 21:46:38 -0700
commit6df78c3bc17e5922792fcef0025043c358daa52f (patch)
tree08cef0a28f498b9bd946714d4bc91ddf284fa166 /test
parent61b70778bdf975957d45432987dde16029aca69a (diff)
downloadzig-6df78c3bc17e5922792fcef0025043c358daa52f.tar.gz
zig-6df78c3bc17e5922792fcef0025043c358daa52f.zip
Sema: mark pointers to inline functions as comptime-only
This is supposed to be the case, similar to how pointers to generic functions are comptime-only (several pieces of logic already assumed this). These types being considered runtime was causing `dbg_var_val` AIR instructions to be wrongly emitted for such values, causing codegen backends to create a runtime reference to the inline function, which (at least on the LLVM backend) triggers an error. Resolves: #38
Diffstat (limited to 'test')
-rw-r--r--test/behavior/call.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/call.zig b/test/behavior/call.zig
index d641d5d5ba..6be66da174 100644
--- a/test/behavior/call.zig
+++ b/test/behavior/call.zig
@@ -491,3 +491,13 @@ test "argument to generic function has correct result type" {
try S.doTheTest();
try comptime S.doTheTest();
}
+
+test "call inline fn through pointer" {
+ const S = struct {
+ inline fn foo(x: u8) !void {
+ try expect(x == 123);
+ }
+ };
+ const f = &S.foo;
+ try f(123);
+}