toml: fix implicit array allocation (#12553)
parent
49cd1b3d59
commit
0779b5fd8e
|
@ -776,16 +776,19 @@ pub fn (mut p Parser) double_array_of_tables(mut table map[string]ast.Value) ? {
|
||||||
// Implicit allocation
|
// Implicit allocation
|
||||||
if p.last_aot.len == 0 {
|
if p.last_aot.len == 0 {
|
||||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'implicit allocation of array for dotted key `$dotted_key`.')
|
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'implicit allocation of array for dotted key `$dotted_key`.')
|
||||||
table[first.str()] = []ast.Value{}
|
|
||||||
p.last_aot = first
|
p.last_aot = first
|
||||||
// We register this implicit allocation as *explicit* to be able to catch
|
// We register this implicit allocation as *explicit* to be able to catch
|
||||||
// special cases like:
|
// special cases like:
|
||||||
// https://github.com/BurntSushi/toml-test/blob/576db852/tests/invalid/table/array-implicit.toml
|
// https://github.com/BurntSushi/toml-test/blob/576db852/tests/invalid/table/array-implicit.toml
|
||||||
p.explicit_declared << first
|
p.explicit_declared << first
|
||||||
|
|
||||||
t_arr = &(table[p.last_aot.str()] as []ast.Value)
|
mut nm := map[string]ast.Value{}
|
||||||
t_arr << ast.Value(map[string]ast.Value{})
|
nm[last.str()] = []ast.Value{}
|
||||||
p.last_aot_index = t_arr.len - 1
|
table[first.str()] = ast.Value(nm)
|
||||||
|
|
||||||
|
t_arr = &(nm[last.str()] as []ast.Value)
|
||||||
|
t_arr << p.array_of_tables_contents() ?
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||||
' nested array of tables key "$first" does not match "$p.last_aot". (excerpt): "...${p.excerpt()}..."')
|
' nested array of tables key "$first" does not match "$p.last_aot". (excerpt): "...${p.excerpt()}..."')
|
||||||
|
|
|
@ -17,8 +17,6 @@ const (
|
||||||
valid_value_exceptions = [
|
valid_value_exceptions = [
|
||||||
// Integer
|
// Integer
|
||||||
'integer/long.toml', // TODO awaits BUG fix with strconv.parse_int('-9223372036854775808')
|
'integer/long.toml', // TODO awaits BUG fix with strconv.parse_int('-9223372036854775808')
|
||||||
// Table
|
|
||||||
'table/array-implicit.toml',
|
|
||||||
// Date-time
|
// Date-time
|
||||||
'datetime/milliseconds.toml',
|
'datetime/milliseconds.toml',
|
||||||
// Key
|
// Key
|
||||||
|
|
Loading…
Reference in New Issue