x.json2.decoder2: fix array decoding in struct is field, when array is initialized (#24422)

This commit is contained in:
Hitalo Souza 2025-05-06 10:32:53 +01:00 committed by GitHub
parent d9afebc277
commit a412f53e62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View file

@ -618,6 +618,9 @@ fn (mut decoder Decoder) decode_value[T](mut val T) ! {
decoder.decode_map(mut val)!
return
} $else $if T.unaliased_typ is $array {
unsafe {
val.len = 0
}
decoder.decode_array(mut val)!
// return to avoid the next increment of the current node
// this is because the current node is already incremented in the decode_array function