toml: check for text after comma in arrays (#12435)

pull/12441/head
Larpon 2021-11-11 13:55:51 +01:00 committed by GitHub
parent 6f55439930
commit 35f00c9f91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -462,12 +462,7 @@ pub fn (mut p Parser) inline_table(mut tbl map[string]ast.Value) ? {
}
.comma {
p.ignore_while_peek(parser.space_formatting)
if p.peek_tok.kind == .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 {
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()}..."')
@ -693,9 +688,12 @@ pub fn (mut p Parser) array() ?[]ast.Value {
previous_token_was_value = true
}
.comma {
p.ignore_while_peek(parser.space_formatting)
// Trailing commas before array close is allowed
// so we skip `if p.peek_tok.kind == .rsbr { ... }`
if p.peek_tok.kind == .comma {
// so we do not do `if p.peek_tok.kind == .rsbr { ... }`
// Check for known errors:
if p.peek_tok.kind in [.comma, .bare] {
p.next() ? // Forward to the peek_tok
return error(@MOD + '.' + @STRUCT + '.' + @FN +
' unexpected "$p.tok.kind" "$p.tok.lit" at this (excerpt): "...${p.excerpt()}..."')

View File

@ -23,7 +23,6 @@ const (
'inline-table/duplicate-key.toml',
// Array
'array/tables-1.toml',
'array/text-after-array-entries.toml',
]
)