diff --git a/parser.go b/parser.go index 08abf27..e351ce7 100644 --- a/parser.go +++ b/parser.go @@ -510,8 +510,8 @@ func (parser *parser) expandOpAssign(scanner * scanner, tree *ast, tk *Token, al if t, err = tree.addToken(NewToken(tk.row, tk.col, opSym, opString)); err == nil { var subTree *ast - if subTree, err = parser.parseGeneral(scanner, false, allowVarRef, SymSemiColon, SymClosedRound); err == nil { - if scanner.Previous().IsOneOfA(SymSemiColon, SymClosedRound) { + if subTree, err = parser.parseGeneral(scanner, false, allowVarRef, SymSemiColon, SymClosedRound, SymClosedBrace, SymClosedSquare); err == nil { + if scanner.Previous().IsOneOfA(SymSemiColon, SymClosedRound, SymClosedBrace, SymClosedSquare) { if err = scanner.UnreadToken(); err != nil { return } diff --git a/t_expr_test.go b/t_expr_test.go index be1f009..a920064 100644 --- a/t_expr_test.go +++ b/t_expr_test.go @@ -27,7 +27,8 @@ func TestExpr(t *testing.T) { /* 13 */ {`a=3; a*=2+1; a`, int64(9), nil}, /* 14 */ {`a=3; (a*=2)+1; a`, int64(6), nil}, /* 15 */ {`a=3; a*=2)+1; a`, nil, `[1:11] unexpected token ")"`}, - /* 16 */ {` + /* 16 */ {`v=[2]; a=1; v[a-=1]=5; v[0]`, int64(5), nil}, + /* 17 */ {` ds={ "init":func(@end){@current=0 but true}, //"current":func(){current},