json: fix default struct field initialization with long array (#23355)

This commit is contained in:
Felipe Pena 2025-01-03 14:25:21 -03:00 committed by GitHub
parent f821c657a7
commit 5eecd04eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,20 @@
import json
struct Bar {
b []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
struct Foo {
Bar
a []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
fn test_main() {
str := json.encode(Foo{})
assert json.decode(Foo, str)!.str() == 'Foo{
Bar: Bar{
b: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}'
}