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(' $it.op.str() ')
for right in it.right {
f.expr(right)
}
f.writeln('')
}
ast.BranchStmt {
match it.tok.kind {

View File

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