diff --git a/vlib/toml/parser/parser.v b/vlib/toml/parser/parser.v index 6ff8d5b90d..78a03b1df3 100644 --- a/vlib/toml/parser/parser.v +++ b/vlib/toml/parser/parser.v @@ -497,8 +497,13 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? { } else { p.ignore_while(parser.space_formatting) key, val := p.key_value() ? - util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'inserting @5 "$key.str()" = $val.to_json() into ${ptr_str(tbl)}') - tbl[key.str()] = val + key_str := key.str() + if _ := tbl[key_str] { + return error(@MOD + '.' + @STRUCT + '.' + @FN + + ' key "$key_str" is already initialized with a value. At "$p.tok.kind" "$p.tok.lit" in this (excerpt): "...${p.excerpt()}..."') + } + util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'inserting @5 "$key_str" = $val.to_json() into ${ptr_str(tbl)}') + tbl[key_str] = val } previous_token_was_value = true } diff --git a/vlib/toml/tests/burntsushi.toml-test_test.v b/vlib/toml/tests/burntsushi.toml-test_test.v index e4657097ed..8f33e5a446 100644 --- a/vlib/toml/tests/burntsushi.toml-test_test.v +++ b/vlib/toml/tests/burntsushi.toml-test_test.v @@ -19,8 +19,6 @@ const ( 'table/injection-2.toml', 'table/injection-1.toml', 'table/duplicate-table-array.toml', - // Inline-table - 'inline-table/duplicate-key.toml', // Array 'array/tables-1.toml', ]