parser: fix cast or dump arguments ending with comma (#14552)
parent
0a3d41c5d7
commit
a396496b93
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
println(u8(1))
|
||||
dump(1)
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
println(u8(1,),)
|
||||
dump(1,)
|
||||
}
|
|
@ -272,6 +272,9 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr {
|
|||
p.next()
|
||||
p.check(.lpar)
|
||||
expr := p.expr(0)
|
||||
if p.tok.kind == .comma && p.peek_tok.kind == .rpar {
|
||||
p.next()
|
||||
}
|
||||
p.check(.rpar)
|
||||
node = ast.DumpExpr{
|
||||
expr: expr
|
||||
|
|
|
@ -2345,6 +2345,9 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
|||
arg = p.expr(0) // len
|
||||
has_arg = true
|
||||
}
|
||||
if p.tok.kind == .comma && p.peek_tok.kind == .rpar {
|
||||
p.next()
|
||||
}
|
||||
end_pos := p.tok.pos()
|
||||
p.check(.rpar)
|
||||
node = ast.CastExpr{
|
||||
|
|
Loading…
Reference in New Issue