authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-06 01:23:27+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-06 01:23:27+00:00
log5d935e1137ade5450e504ce9bc6bbf32301b0dfd
tree7e679df59cbb8d144078482b457c723f282a6d30
parent75ec7d863efbba9dbb3eefa5e6607a5ef2fe8648
signaturelock-open Commit is signed but in an unrecognized format.

behavior: add test for old bug

Resolves: #18435

1 files changed, 17 insertions(+), 0 deletions(-)

test/behavior/fn.zig+17
......@@ -711,3 +711,20 @@ test "inline call propagates comptime-known argument to generic parameter and re
711711 try expect(a1 == 12340);
712712 try expect(b1 == 12340);
713713}
714
715test "inline function return type is evaluated at comptime" {
716 const S = struct {
717 inline fn assertComptimeAndRet(x: anytype) @TypeOf(x) {
718 if (!@inComptime()) comptime unreachable;
719 return x;
720 }
721
722 inline fn foo(val: anytype) assertComptimeAndRet(u16) {
723 return val;
724 }
725 };
726
727 const result = S.foo(123);
728 comptime assert(@TypeOf(result) == u16);
729 try expect(result == 123);
730}