Skip to content

Commit e954445

Browse files
Reject duplicate arrays (#455)
Fixes #454
1 parent 6b16cbd commit e954445

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

parse.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ func (p *parser) setValue(key string, value any) {
644644
// Note that since it has already been defined (as a hash), we don't
645645
// want to overwrite it. So our business is done.
646646
if p.isArray(keyContext) {
647+
if !p.isImplicit(keyContext) {
648+
if _, ok := hash[key]; ok {
649+
p.panicf("Key '%s' has already been defined.", keyContext)
650+
}
651+
}
647652
p.removeImplicit(keyContext)
648653
hash[key] = value
649654
return

toml_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,6 @@ func runTomlTest(t *testing.T, includeNext bool, wantFail ...string) {
315315
Parser: parser{},
316316
RunTests: runTests,
317317
SkipTests: []string{
318-
"invalid/key/duplicate-keys-08",
319-
320318
// Will be fixed in Go 1.23: https://github.com/BurntSushi/toml/issues/407
321319
"invalid/datetime/offset-overflow-hour",
322320
"invalid/datetime/offset-overflow-minute",

0 commit comments

Comments
 (0)