mirror of
https://github.com/golang/go
synced 2024-11-24 07:30:10 -07:00
cmd/compile/internal/typecheck: simplify checkassign
After CL 281543, checkassign do not have to check assignment in range loop anymore, thus its first parameter is un-used. Change-Id: Idbc46fcb81c3dd5edc87308d228c1a15ca5faf7e Reviewed-on: https://go-review.googlesource.com/c/go/+/396615 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d1060d8e82
commit
f5a42cd4b4
@ -78,7 +78,7 @@ func typecheckrangeExpr(n *ir.RangeStmt) {
|
||||
base.ErrorfAt(n.Pos(), "cannot assign type %v to %L in range%s", t, nn, why)
|
||||
}
|
||||
}
|
||||
checkassign(n, nn)
|
||||
checkassign(nn)
|
||||
}
|
||||
}
|
||||
do(n.Key, tk)
|
||||
@ -137,7 +137,7 @@ func assign(stmt ir.Node, lhs, rhs []ir.Node) {
|
||||
if lhs[i].Typecheck() == 0 {
|
||||
lhs[i] = AssignExpr(lhs[i])
|
||||
}
|
||||
checkassign(stmt, lhs[i])
|
||||
checkassign(lhs[i])
|
||||
}
|
||||
|
||||
assignType := func(i int, typ *types.Type) {
|
||||
|
@ -488,7 +488,7 @@ func typecheck1(n ir.Node, top int) ir.Node {
|
||||
case ir.OASOP:
|
||||
n := n.(*ir.AssignOpStmt)
|
||||
n.X, n.Y = Expr(n.X), Expr(n.Y)
|
||||
checkassign(n, n.X)
|
||||
checkassign(n.X)
|
||||
if n.IncDec && !okforarith[n.X.Type().Kind()] {
|
||||
base.Errorf("invalid operation: %v (non-numeric type %v)", n, n.X.Type())
|
||||
return n
|
||||
@ -1562,7 +1562,7 @@ func checklvalue(n ir.Node, verb string) {
|
||||
}
|
||||
}
|
||||
|
||||
func checkassign(stmt ir.Node, n ir.Node) {
|
||||
func checkassign(n ir.Node) {
|
||||
// have already complained about n being invalid
|
||||
if n.Type() == nil {
|
||||
if base.Errors() == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user