From bf402649411f8ddbfab94dbab6088215d67e0e00 Mon Sep 17 00:00:00 2001 From: K4 Date: Sun, 12 Apr 2026 17:14:06 +0300 Subject: [PATCH] add test for comptime-only functions --- test/behavior/fn.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig index 358ca7b629..aa6ca41c74 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; +}