behavior: add test for old bug

Resolves: #18435
This commit is contained in:
mlugg 2025-02-06 01:23:27 +00:00
parent 75ec7d863e
commit 5d935e1137
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E

View File

@ -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);
}