toml: check for text after comma in arrays (#12435)
parent
6f55439930
commit
35f00c9f91
|
@ -462,12 +462,7 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? {
|
||||||
}
|
}
|
||||||
.comma {
|
.comma {
|
||||||
p.ignore_while_peek(parser.space_formatting)
|
p.ignore_while_peek(parser.space_formatting)
|
||||||
if p.peek_tok.kind == .rcbr {
|
if p.peek_tok.kind in [.comma, .rcbr] {
|
||||||
p.next() ? // Forward to the peek_tok
|
|
||||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
|
||||||
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')
|
|
||||||
}
|
|
||||||
if p.peek_tok.kind == .comma {
|
|
||||||
p.next() ? // Forward to the peek_tok
|
p.next() ? // Forward to the peek_tok
|
||||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||||
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')
|
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')
|
||||||
|
@ -693,9 +688,12 @@ pub fn (mut p Parser) array() ?[]ast.Value {
|
||||||
previous_token_was_value = true
|
previous_token_was_value = true
|
||||||
}
|
}
|
||||||
.comma {
|
.comma {
|
||||||
|
p.ignore_while_peek(parser.space_formatting)
|
||||||
// Trailing commas before array close is allowed
|
// Trailing commas before array close is allowed
|
||||||
// so we skip `if p.peek_tok.kind == .rsbr { ... }`
|
// so we do not do `if p.peek_tok.kind == .rsbr { ... }`
|
||||||
if p.peek_tok.kind == .comma {
|
|
||||||
|
// Check for known errors:
|
||||||
|
if p.peek_tok.kind in [.comma, .bare] {
|
||||||
p.next() ? // Forward to the peek_tok
|
p.next() ? // Forward to the peek_tok
|
||||||
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
return error(@MOD + '.' + @STRUCT + '.' + @FN +
|
||||||
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')
|
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')
|
||||||
|
|
|
@ -23,7 +23,6 @@ const (
|
||||||
'inline-table/duplicate-key.toml',
|
'inline-table/duplicate-key.toml',
|
||||||
// Array
|
// Array
|
||||||
'array/tables-1.toml',
|
'array/tables-1.toml',
|
||||||
'array/text-after-array-entries.toml',
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue