Skip to content

Commit

Permalink
Fix panic when trying to set subkey for a value that's not a table
Browse files Browse the repository at this point in the history
Would panic for inline tables; regression added in 4223137.

Fixes #403
  • Loading branch information
arp242 committed Jan 3, 2024
1 parent c299e75 commit 0e879cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 4 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,10 @@ func (p *parser) valueInlineTable(it item, parentIsArray bool) (any, tomlType) {
h = make(map[string]any)
hash[c] = h
}
hash = h.(map[string]any)
hash, ok = h.(map[string]any)
if !ok {
p.panicf("%q is not a table", p.context)
}
}
hash[p.currentKey] = val

Expand Down
3 changes: 0 additions & 3 deletions toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,6 @@ func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) {
Parser: parser{},
RunTests: runTests,
SkipTests: []string{
// TODO: https://github.com/BurntSushi/toml/issues/403
"invalid/inline-table/overwrite-10",

// These tests are fine, just doesn't deal well with empty output.
"valid/comment/noeol",
"valid/comment/nonascii",
Expand Down

0 comments on commit 0e879cb

Please sign in to comment.