aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/behavior/fn.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig
index 6cf0f15795..dbaf6b0f2b 100644
--- a/test/behavior/fn.zig
+++ b/test/behavior/fn.zig
@@ -711,3 +711,20 @@ test "inline call propagates comptime-known argument to generic parameter and re
try expect(a1 == 12340);
try expect(b1 == 12340);
}
+
+test "inline function return type is evaluated at comptime" {
+ const S = struct {
+ inline fn assertComptimeAndRet(x: anytype) @TypeOf(x) {
+ if (!@inComptime()) comptime unreachable;
+ return x;
+ }
+
+ inline fn foo(val: anytype) assertComptimeAndRet(u16) {
+ return val;
+ }
+ };
+
+ const result = S.foo(123);
+ comptime assert(@TypeOf(result) == u16);
+ try expect(result == 123);
+}