toml: check for single-key reassignment in inline tables (#12436)
parent
35f00c9f91
commit
c8cb1bf6b4
|
@ -497,8 +497,13 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? {
|
||||||
} else {
|
} else {
|
||||||
p.ignore_while(parser.space_formatting)
|
p.ignore_while(parser.space_formatting)
|
||||||
key, val := p.key_value() ?
|
key, val := p.key_value() ?
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'inserting @5 "$key.str()" = $val.to_json() into ${ptr_str(tbl)}')
|
key_str := key.str()
|
||||||
tbl[key.str()] = val
|
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
|
previous_token_was_value = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@ const (
|
||||||
'table/injection-2.toml',
|
'table/injection-2.toml',
|
||||||
'table/injection-1.toml',
|
'table/injection-1.toml',
|
||||||
'table/duplicate-table-array.toml',
|
'table/duplicate-table-array.toml',
|
||||||
// Inline-table
|
|
||||||
'inline-table/duplicate-key.toml',
|
|
||||||
// Array
|
// Array
|
||||||
'array/tables-1.toml',
|
'array/tables-1.toml',
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue