diff --git a/src/cmd/compile/internal/types2/assignments.go b/src/cmd/compile/internal/types2/assignments.go index afbb1186b5a..9b130b48e1a 100644 --- a/src/cmd/compile/internal/types2/assignments.go +++ b/src/cmd/compile/internal/types2/assignments.go @@ -99,7 +99,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { } func (check *Checker) initConst(lhs *Const, x *operand) { - if x.mode == invalid || x.typ == Typ[Invalid] || lhs.typ == Typ[Invalid] { + if x.mode == invalid || lhs.typ == Typ[Invalid] { if lhs.typ == nil { lhs.typ = Typ[Invalid] } @@ -130,7 +130,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) { } func (check *Checker) initVar(lhs *Var, x *operand, context string) Type { - if x.mode == invalid || x.typ == Typ[Invalid] || lhs.typ == Typ[Invalid] { + if x.mode == invalid || lhs.typ == Typ[Invalid] { if lhs.typ == nil { lhs.typ = Typ[Invalid] } @@ -198,10 +198,6 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type { v.used = v_used // restore v.used } - if x.mode == invalid || x.typ == Typ[Invalid] { - return Typ[Invalid] - } - // spec: "Each left-hand side operand must be addressable, a map index // expression, or the blank identifier. Operands may be parenthesized." switch x.mode { @@ -228,7 +224,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type { // assignVar checks the assignment lhs = x and returns the type of x. // If the assignment is invalid, the result is nil. func (check *Checker) assignVar(lhs syntax.Expr, x *operand) Type { - if x.mode == invalid || x.typ == Typ[Invalid] { + if x.mode == invalid { check.useLHS(lhs) return nil } diff --git a/src/go/types/assignments.go b/src/go/types/assignments.go index e1b22d16ad4..9d6a1ef4ed3 100644 --- a/src/go/types/assignments.go +++ b/src/go/types/assignments.go @@ -97,7 +97,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) { } func (check *Checker) initConst(lhs *Const, x *operand) { - if x.mode == invalid || x.typ == Typ[Invalid] || lhs.typ == Typ[Invalid] { + if x.mode == invalid || lhs.typ == Typ[Invalid] { if lhs.typ == nil { lhs.typ = Typ[Invalid] } @@ -128,7 +128,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) { } func (check *Checker) initVar(lhs *Var, x *operand, context string) Type { - if x.mode == invalid || x.typ == Typ[Invalid] || lhs.typ == Typ[Invalid] { + if x.mode == invalid || lhs.typ == Typ[Invalid] { if lhs.typ == nil { lhs.typ = Typ[Invalid] } @@ -196,10 +196,6 @@ func (check *Checker) lhsVar(lhs ast.Expr) Type { v.used = v_used // restore v.used } - if x.mode == invalid || x.typ == Typ[Invalid] { - return Typ[Invalid] - } - // spec: "Each left-hand side operand must be addressable, a map index // expression, or the blank identifier. Operands may be parenthesized." switch x.mode { @@ -226,7 +222,7 @@ func (check *Checker) lhsVar(lhs ast.Expr) Type { // assignVar checks the assignment lhs = x and returns the type of x. // If the assignment is invalid, the result is nil. func (check *Checker) assignVar(lhs ast.Expr, x *operand) Type { - if x.mode == invalid || x.typ == Typ[Invalid] { + if x.mode == invalid { check.useLHS(lhs) return nil }