parser: fix cast or dump arguments ending with comma (#14552)
parent
63d15086e7
commit
79d861ad4f
|
@ -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