File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1191,13 +1191,29 @@ impl scopeParser {
11911191 self.pushErr(token, "invalid syntax")
11921192 ret nil, false
11931193 } else if i+1 < len(tokens) {
1194+ // Expression is in the same statement,
1195+ // following the assignment operator.
11941196 assign.Op = tokens[i]
11951197 if assign.Op.ID != token::ASSIGN {
11961198 self.pushErr(assign.Op, "assignment operation @ requires single-valued expressions", assign.Op.Kind)
11971199 }
11981200 i++
11991201 mut exprTokens := tokens[i:]
12001202 assign.Y = self.p.buildExpr(exprTokens)
1203+ } else {
1204+ // The assignment operator exist, but expression is not.
1205+ // Probably the following statement is the expression.
1206+ // We must try to handle next statement as expression.
1207+ assign.Op = tokens[i]
1208+ if assign.Op.ID != token::ASSIGN {
1209+ self.pushErr(assign.Op, "assignment operation @ requires single-valued expressions", assign.Op.Kind)
1210+ }
1211+ if self.isLastSt() {
1212+ self.pushErr(assign.Op, "expected expression")
1213+ ret nil, false
1214+ }
1215+ mut exprTokens := self.next().tokens
1216+ assign.Y = self.p.buildExpr(exprTokens)
12011217 }
12021218
12031219 ok := self.buildDeclAssign1(rang, assign)
You can’t perform that action at this time.
0 commit comments