Commit 5d935e1137

mlugg <mlugg@mlugg.co.uk>
2025-02-06 02:23:27
behavior: add test for old bug
Resolves: #18435
1 parent 75ec7d8
Changed files (1)
test
behavior
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);
+}