|
@@ -542,6 +542,10 @@ func (d *decoder) sequence(n *node, out reflect.Value) (good bool) {
|
|
|
switch out.Kind() {
|
|
switch out.Kind() {
|
|
|
case reflect.Slice:
|
|
case reflect.Slice:
|
|
|
out.Set(reflect.MakeSlice(out.Type(), l, l))
|
|
out.Set(reflect.MakeSlice(out.Type(), l, l))
|
|
|
|
|
+ case reflect.Array:
|
|
|
|
|
+ if l != out.Len() {
|
|
|
|
|
+ failf("invalid array: want %d elements but got %d", out.Len(), l)
|
|
|
|
|
+ }
|
|
|
case reflect.Interface:
|
|
case reflect.Interface:
|
|
|
// No type hints. Will have to use a generic sequence.
|
|
// No type hints. Will have to use a generic sequence.
|
|
|
iface = out
|
|
iface = out
|
|
@@ -560,7 +564,9 @@ func (d *decoder) sequence(n *node, out reflect.Value) (good bool) {
|
|
|
j++
|
|
j++
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- out.Set(out.Slice(0, j))
|
|
|
|
|
|
|
+ if out.Kind() != reflect.Array {
|
|
|
|
|
+ out.Set(out.Slice(0, j))
|
|
|
|
|
+ }
|
|
|
if iface.IsValid() {
|
|
if iface.IsValid() {
|
|
|
iface.Set(out)
|
|
iface.Set(out)
|
|
|
}
|
|
}
|