From 9d1d8f26c9189fff7d7445dde8c1cc2a60bbcdd8 Mon Sep 17 00:00:00 2001 From: Simon Hartcher Date: Wed, 4 Jun 2025 15:59:00 +1000 Subject: [PATCH] chore: add comment to explain fix --- codegen/src/main.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codegen/src/main.zig b/codegen/src/main.zig index 2ca13db..60cc3a6 100644 --- a/codegen/src/main.zig +++ b/codegen/src/main.zig @@ -1010,6 +1010,9 @@ fn writeStructureJson(params: WriteMemberJsonParams, writer: std.io.AnyWriter) ! try writer.writeAll("try jw.beginObject();\n"); try writer.writeAll("{\n"); + // this is a workaround in case a child structure doesn't have any fields + // and therefore doesn't use the structure variable so we capture it here. + // the compiler should optimize this away try writer.print("const unused_capture_{s} = {s};\n", .{ structure_name, object_value }); try writer.print("_ = unused_capture_{s};\n", .{structure_name});