mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
toml: fix implicit array allocation (#12553)
This commit is contained in:
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
|
||||
if p.last_aot.len == 0 {
|
||||
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'implicit allocation of array for dotted key `$dotted_key`.')
|
||||
table[first.str()] = []ast.Value{}
|
||||
p.last_aot = first
|
||||
// We register this implicit allocation as *explicit* to be able to catch
|
||||
// special cases like:
|
||||
// https://github.com/BurntSushi/toml-test/blob/576db852/tests/invalid/table/array-implicit.toml
|
||||
p.explicit_declared << first
|
||||
|
||||
t_arr = &(table[p.last_aot.str()] as []ast.Value)
|
||||
t_arr << ast.Value(map[string]ast.Value{})
|
||||
p.last_aot_index = t_arr.len - 1
|
||||
mut nm := map[string]ast.Value{}
|
||||
nm[last.str()] = []ast.Value{}
|
||||
table[first.str()] = ast.Value(nm)
|
||||
|
||||
t_arr = &(nm[last.str()] as []ast.Value)
|
||||
t_arr << p.array_of_tables_contents() ?
|
||||
return
|
||||
} else {
|
||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||
' nested array of tables key "$first" does not match "$p.last_aot". (excerpt): "...${p.excerpt()}..."')
|
||||
|
@ -17,8 +17,6 @@ const (
|
||||
valid_value_exceptions = [
|
||||
// Integer
|
||||
'integer/long.toml', // TODO awaits BUG fix with strconv.parse_int('-9223372036854775808')
|
||||
// Table
|
||||
'table/array-implicit.toml',
|
||||
// Date-time
|
||||
'datetime/milliseconds.toml',
|
||||
// Key
|
||||
|
Loading…
Reference in New Issue
Block a user