authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-03-28 02:04:47 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-03-28 02:04:47 -07:00
loge7a810a3694f08b185836898394c95879d04dd1f
treeb6b76fcdd07b364a4c8aedaec746dd1598282e7a
parent303ff1d58b47da1e64f24cf927178456140153bf

accept ints in #if and #ifnot condition blocks


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

src/lib.zig+2
...@@ -181,6 +181,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -181,6 +181,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
181 switch (comptime TI) {181 switch (comptime TI) {
182 .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, x),182 .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, x),
183 .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, x),183 .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, x),
184 .Int => try doif(alloc, writer, body, bottom, data, ctx, opts, x != 0),
184 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})),185 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #if block", .{@typeName(T)})),
185 }186 }
186 },187 },
...@@ -211,6 +212,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d...@@ -211,6 +212,7 @@ fn do(alloc: std.mem.Allocator, writer: anytype, comptime value: astgen.Value, d
211 switch (comptime TI) {212 switch (comptime TI) {
212 .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, !x),213 .Bool => try doif(alloc, writer, body, bottom, data, ctx, opts, !x),
213 .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, !x),214 .Optional => try docap(alloc, writer, body, bottom, data, ctx, opts, !x),
215 .Int => try doif(alloc, writer, body, bottom, data, ctx, opts, x == 0),
214 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})),216 else => @compileError(std.fmt.comptimePrint("pek: unable to use '{s}' in an #ifnot block", .{@typeName(T)})),
215 }217 }
216 },218 },