authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 13:58:27 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-14 13:58:27 -07:00
logd644cb06a389c433e1493ea19182fe04f0657edb
tree17fa423c03430664782a99c9bd6442fca632d4b9
parent48b67051c2548d668e1bde1ed93a01eb2f21d385

add support for indexables in `#if`


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

src/lib.zig+4
...@@ -101,6 +101,10 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,...@@ -101,6 +101,10 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,
101 },101 },
102 .@"if" => {102 .@"if" => {
103 comptime assertEqual(v.args.len, 1);103 comptime assertEqual(v.args.len, 1);
104 if (comptime std.meta.trait.isIndexable(T)) {
105 try doif(alloc, writer, body, bottom, data, ctx, indent, flag1, x.len > 0);
106 return;
107 }
104 switch (comptime TI) {108 switch (comptime TI) {
105 .Bool => try doif(alloc, writer, body, bottom, data, ctx, indent, flag1, x),109 .Bool => try doif(alloc, writer, body, bottom, data, ctx, indent, flag1, x),
106 .Optional => try docap(alloc, writer, body, bottom, data, ctx, indent, flag1, x),110 .Optional => try docap(alloc, writer, body, bottom, data, ctx, indent, flag1, x),