From: Cuong Manh Le Date: Wed, 30 Mar 2022 02:10:06 +0000 (+0700) Subject: cmd/compile/internal/typecheck: simplify checkassign X-Git-Tag: go1.19beta1~874 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f5a42cd4b482a595a710129a25ffb5facc655569;p=gostls13.git 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 Run-TryBot: Cuong Manh Le TryBot-Result: Gopher Robot Reviewed-by: Matthew Dempsky --- diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go index 16e24a0491..60bac77d19 100644 --- a/src/cmd/compile/internal/typecheck/stmt.go +++ b/src/cmd/compile/internal/typecheck/stmt.go @@ -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) { diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index b5108eab84..85de653a82 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -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 {