From e7a810a3694f08b185836898394c95879d04dd1f Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 28 Mar 2025 02:04:47 -0700 Subject: [PATCH] accept ints in #if and #ifnot condition blocks --- src/lib.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.zig b/src/lib.zig index f5b446ebb11c89b2e38b25c961418a5a6bf1cfa9..87f407f6b2960acca52a64bb92d73a85d0d4058d 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -181,6 +181,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d switch (comptime TI) { .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, x), .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, x), + .Int => try doif(alloc, writer, body, bottom, data, ctx, opts, x != 0), else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})), } }, @@ -211,6 +212,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d switch (comptime TI) { .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, !x), .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, !x), + .Int => try doif(alloc, writer, body, bottom, data, ctx, opts, x == 0), else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})), } }, -- 2.54.0