} else {
y = p.parseList(true)
}
- as := &ast.AssignStmt{Lhs: x, TokPos: pos, Tok: tok, Rhs: y}
- if tok == token.DEFINE {
- p.checkAssignStmt(as)
- }
- return as, isRange
+ return &ast.AssignStmt{Lhs: x, TokPos: pos, Tok: tok, Rhs: y}, isRange
}
if len(x) > 1 {
return &ast.ExprStmt{X: x[0]}, false
}
-func (p *parser) checkAssignStmt(as *ast.AssignStmt) {
- for _, x := range as.Lhs {
- if _, isIdent := x.(*ast.Ident); !isIdent {
- p.errorExpected(x.Pos(), "identifier on left side of :=")
- }
- }
-}
-
func (p *parser) parseCallExpr(callType string) *ast.CallExpr {
x := p.parseRhs() // could be a conversion: (some type)(x)
if t := unparen(x); t != x {
pos := p.pos
p.next()
rhs := p.parseRhs()
- as := &ast.AssignStmt{Lhs: lhs, TokPos: pos, Tok: tok, Rhs: []ast.Expr{rhs}}
- if tok == token.DEFINE {
- p.checkAssignStmt(as)
- }
- comm = as
+ comm = &ast.AssignStmt{Lhs: lhs, TokPos: pos, Tok: tok, Rhs: []ast.Expr{rhs}}
} else {
// lhs must be single receive operation
if len(lhs) > 1 {
`package p; func f() { switch t /* ERROR "expected switch expression" */ = t.(type), t {} };`,
`package p; func f() { _ = (<-<- /* ERROR "expected 'chan'" */ chan int)(nil) };`,
`package p; func f() { _ = (<-chan<-chan<-chan<-chan<-chan<- /* ERROR "expected channel type" */ int)(nil) };`,
- `package p; func f() { var t []int; t /* ERROR "expected identifier on left side of :=" */ [0] := 0 };`,
`package p; func f() { if x := g(); x /* ERROR "expected boolean expression" */ = 0 {}};`,
`package p; func f() { _ = x = /* ERROR "expected '=='" */ 0 {}};`,
`package p; func f() { _ = 1 == func()int { var x bool; x = x = /* ERROR "expected '=='" */ true; return x }() };`,