Skip to content

Commit

Permalink
behavior: add test for old bug
Browse files Browse the repository at this point in the history
Resolves: ziglang#18435
  • Loading branch information
mlugg committed Feb 6, 2025
1 parent 75ec7d8 commit 5d935e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/behavior/fn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 5d935e1

Please sign in to comment.