From f123fb1e916bfe272bf800dd87beb30c05ee5a6c Mon Sep 17 00:00:00 2001 From: andzdroid Date: Sun, 15 Mar 2026 12:48:41 +0000 Subject: [PATCH] encoding/cbor: fix order-dependent partial unmarshals --- core/encoding/cbor/unmarshal.odin | 13 +------------ tests/core/encoding/cbor/test_core_cbor.odin | 2 ++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/core/encoding/cbor/unmarshal.odin b/core/encoding/cbor/unmarshal.odin index 043b2ec60..9a1e584fa 100644 --- a/core/encoding/cbor/unmarshal.odin +++ b/core/encoding/cbor/unmarshal.odin @@ -661,8 +661,7 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, unknown := length == -1 fields := reflect.struct_fields_zipped(ti.id) - idx := 0 - for ; idx < len(fields) && (unknown || idx < length); idx += 1 { + for idx := 0; unknown || idx < length; idx += 1 { // Decode key, keys can only be strings. key: string if keyv, kerr := decode_key(d, v, context.temp_allocator); unknown && kerr == .Break { @@ -710,16 +709,6 @@ _unmarshal_map :: proc(d: Decoder, v: any, ti: ^reflect.Type_Info, hdr: Header, _unmarshal_value(d, fany, _decode_header(r) or_return) or_return } - // If there are fields left in the map that did not get decoded into the struct, decode and discard them. - if !unknown { - for _ in idx..