authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-06 00:51:44+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-06 00:52:03+00:00
log164700740b9530ffc7622f9b4c664278a7f68160
tree43c4c9b876b139dbac4e40afd3fa93f3ec2f289d
parent6bd92a21b7f31de913c7383ea380f3b68d387395
signaturelock-open Commit is signed but in an unrecognized format.

behavior: add test for old bug

Resolves: #13013

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

test/behavior/generics.zig+16
......@@ -589,3 +589,19 @@ comptime {
589589 // should override the result of the previous analysis.
590590 for (0..2) |_| _ = fn (void) void;
591591}
592
593test "generic parameter resolves to comptime-only type but is not marked comptime" {
594 const S = struct {
595 fn foo(comptime T: type, rt_false: bool, func: fn (T) void) T {
596 if (rt_false) _ = foo(T, rt_false, func);
597 return 123;
598 }
599 fn bar(_: u8) void {}
600 };
601
602 const rt_result = S.foo(u8, false, S.bar);
603 try expect(rt_result == 123);
604
605 const ct_result = comptime S.foo(u8, false, S.bar);
606 comptime std.debug.assert(ct_result == 123);
607}