fmt: process assignment statement correctly

pull/3826/head
Alexey 2020-02-23 13:22:07 +03:00 committed by GitHub
parent 2eb4f663d6
commit 26fa833984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -106,10 +106,11 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
f.write(', ') f.write(', ')
} }
} }
f.write(' = ') f.write(' $it.op.str() ')
for right in it.right { for right in it.right {
f.expr(right) f.expr(right)
} }
f.writeln('')
} }
ast.BranchStmt { ast.BranchStmt {
match it.tok.kind { match it.tok.kind {

View File

@ -1450,11 +1450,13 @@ pub fn (p mut Parser) assign_stmt() ast.AssignStmt {
break break
} }
} }
op := p.tok.kind
p.next() // :=, = p.next() // :=, =
expr,_ := p.expr(0) expr,_ := p.expr(0)
return ast.AssignStmt{ return ast.AssignStmt{
left: idents left: idents
right: [expr] right: [expr]
op: op
} }
} }