Don't crash when assigning group array to array
This commit is contained in:
@@ -107,7 +107,7 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
|
||||
var array []*TomlTree
|
||||
if destTree == nil {
|
||||
array = make([]*TomlTree, 0)
|
||||
} else if destTree.([]*TomlTree) != nil {
|
||||
} else if target, ok := destTree.([]*TomlTree); ok && target != nil {
|
||||
array = destTree.([]*TomlTree)
|
||||
} else {
|
||||
p.raiseError(key, "key %s is already assigned and not of type group array", key)
|
||||
|
||||
@@ -626,3 +626,10 @@ func TestDoubleEqual(t *testing.T) {
|
||||
t.Error("Bad error message:", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroupArrayReassign(t *testing.T) {
|
||||
_, err := Load("[hello]\n[[hello]]")
|
||||
if err.Error() != "(2, 3): key \"hello\" is already assigned and not of type group array" {
|
||||
t.Error("Bad error message:", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user