fix: extractAlloc should correctly handle optional values that are null

This commit is contained in:
CJ van den Berg 2026-03-12 19:35:36 +01:00
parent 1ddcaf5e9e
commit 5b856423d1
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -1173,6 +1173,10 @@ fn GenericExtractorAlloc(T: type) type {
else => extractError(T), else => extractError(T),
}, },
.optional => |opt_info| { .optional => |opt_info| {
if (try matchNull(iter)) {
self.dest.* = null;
return true;
}
var nested: opt_info.child = undefined; var nested: opt_info.child = undefined;
const extractor = GenericExtractorAlloc(opt_info.child).init(&nested, self.allocator); const extractor = GenericExtractorAlloc(opt_info.child).init(&nested, self.allocator);
if (try extractor.extract(iter)) { if (try extractor.extract(iter)) {