authorgravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-07-20 22:29:10-07:00
committergravatar for mason@gamesbymason.comMason Remaley <mason@gamesbymason.com> 2026-09-26 12:35:38-07:00
logab52406e0c5598b651b11f3f7f93ad5ddb875896
tree38f71df008b73c2f53bb3bc35233493a5de62a4e
parentb3bb6d923fef98b0b0da8f0848e235b06a9e473f

Fix optional initialization


1 files changed, 5 insertions(+), 3 deletions(-)

lib/std/zon/parse.zig+5-3
...@@ -459,10 +459,12 @@ const Parser = struct {...@@ -459,10 +459,12 @@ const Parser = struct {
459 switch (@typeInfo(@TypeOf(out.*))) {459 switch (@typeInfo(@TypeOf(out.*))) {
460 .optional => |optional| if (node.get(self.zoir) == .null) {460 .optional => |optional| if (node.get(self.zoir) == .null) {
461 out.* = null;461 out.* = null;
462 } else if (initialized and out.* != null) {
463 try self.parseExprInnerInto(node, &out.*.?, true);
462 } else {464 } else {
463 const child_initialized = initialized and out.* != null;465 var some: optional.child = undefined;
464 if (!child_initialized) out.* = @as(optional.child, undefined);466 try self.parseExprInnerInto(node, &some, false);
465 try self.parseExprInnerInto(node, &out.*.?, child_initialized);467 out.* = some;
466 },468 },
467 .bool => out.* = try self.parseBool(node),469 .bool => out.* = try self.parseBool(node),
468 .int => out.* = try self.parseInt(@TypeOf(out.*), node),470 .int => out.* = try self.parseInt(@TypeOf(out.*), node),