Decode: error on array table mismatched type (#804)

Prevent the decoder from continuing if it encounters a type it cannot decode an
array table into.

Fixes #799
This commit is contained in:
Thomas Pelletier
2022-08-15 16:38:07 -04:00
committed by GitHub
parent 2d8433b69e
commit 7baa23f493
2 changed files with 40 additions and 2 deletions
+2 -2
View File
@@ -344,9 +344,9 @@ func (d *decoder) handleArrayTableCollectionLast(key ast.Iterator, v reflect.Val
elem := v.Index(idx)
_, err := d.handleArrayTable(key, elem)
return v, err
default:
return reflect.Value{}, fmt.Errorf("toml: cannot decode array table into a %s", v.Type())
}
return d.handleArrayTable(key, v)
}
// When parsing an array table expression, each part of the key needs to be