From 26fa833984cc7be1eb449bb6b4a5b9d958f73605 Mon Sep 17 00:00:00 2001 From: Alexey Date: Sun, 23 Feb 2020 13:22:07 +0300 Subject: [PATCH] fmt: process assignment statement correctly --- vlib/v/fmt/fmt.v | 3 ++- vlib/v/parser/parser.v | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index aa10ea022a..5b220efe55 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -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 { diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 1fa633801e..f2241f6fd0 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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 } }