]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/typecheck: simplify checkassign
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 30 Mar 2022 02:10:06 +0000 (09:10 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 30 Mar 2022 02:40:41 +0000 (02:40 +0000)
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>
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/typecheck.go

index 16e24a049177fb3c3cb84af9d19e0cc1b8226a28..60bac77d19c2f63055e727290eb8a392b003d4d7 100644 (file)
@@ -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) {
index b5108eab847d4c30deb5421cd46125f5a4091f6d..85de653a82a6c41677a110f3bde20586c7d059eb 100644 (file)
@@ -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 {