diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig index 358ca7b62976977ee862378ee15b75028cd2672c..aa6ca41c74d6bd95f52dc53800e3008c172d33e3 100644 --- a/test/behavior/fn.zig +++ b/test/behavior/fn.zig @@ -770,3 +770,15 @@ test "return undefined pointer from function, directly and by expired local" { const bad_ptr_2 = S.returnStackPointer(); _ = bad_ptr_2; // dereferencing this would be illegal behavior } + +test "a function that works at comptime but not runtime" { + const a = comptime testComptimeOnlyFn(1, 1); + try expect(a[0] == 1); + try expect(a[1] == 2); +} + +fn testComptimeOnlyFn(x: u32, y: u32) [2]u8 { + const xa: [x]u8 = .{1}; + const ya: [y]u8 = .{2}; + return xa ++ ya; +}