mirror of
https://github.com/golang/go
synced 2024-11-23 00:30:07 -07:00
go/types, types2: remove unnecessary tests for x.typ == Typ[Invalid]
In the worst case (x.mode != invalid but x.typ == Typ[Invalid]) we may get unexpected additional errors; but we don't seem to have any such situations, at least in the existing tests. Change-Id: I86ae607b4ac9b926264bb6a967627c40e5a86ade Reviewed-on: https://go-review.googlesource.com/c/go/+/478715 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
abf9b112fd
commit
4c49d52439
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user