quick fix for compound assignment operators

a better fix would be to change lot of things inside parser
This commit is contained in:
Henrixounez 2019-06-25 15:26:26 +02:00 committed by Alex Medvednikov
parent 218a46611e
commit 663cbadf60
2 changed files with 29 additions and 2 deletions

View file

@ -1018,10 +1018,15 @@ fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) {
if is_str {
p.gen('= string_add($v.name, ')// TODO can't do `foo.bar += '!'`
}
else {
else if !is_map {
p.gen(' += ')
}
default: p.gen(' ' + p.tok.str() + ' ')
default:
if tok != MINUS_ASSIGN && tok != MULT_ASSIGN && tok != XOR_ASSIGN
&& tok != MOD_ASSIGN && tok != AND_ASSIGN && tok != OR_ASSIGN
&& tok != RIGHT_SHIFT_ASSIGN && tok != LEFT_SHIFT_ASSIGN && tok != DIV_ASSIGN {
p.gen(' ' + p.tok.str() + ' ')
}
}
p.fgen(' ' + p.tok.str() + ' ')
p.next()