aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/typecheck/expr.go6
-rw-r--r--src/cmd/compile/internal/typecheck/stmt.go4
-rw-r--r--src/cmd/compile/internal/typecheck/subr.go11
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go2
4 files changed, 10 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go
index 83d1355fe5..24c677e753 100644
--- a/src/cmd/compile/internal/typecheck/expr.go
+++ b/src/cmd/compile/internal/typecheck/expr.go
@@ -69,7 +69,7 @@ func tcArith(n ir.Node, op ir.Op, l, r ir.Node) (ir.Node, ir.Node, *types.Type)
// The conversion allocates, so only do it if the concrete type is huge.
converted := false
if r.Type().Kind() != types.TBLANK {
- aop, _ = Assignop(l.Type(), r.Type())
+ aop, _ = assignOp(l.Type(), r.Type())
if aop != ir.OXXX {
if r.Type().IsInterface() && !l.Type().IsInterface() && !types.IsComparable(l.Type()) {
base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(l.Type()))
@@ -88,7 +88,7 @@ func tcArith(n ir.Node, op ir.Op, l, r ir.Node) (ir.Node, ir.Node, *types.Type)
}
if !converted && l.Type().Kind() != types.TBLANK {
- aop, _ = Assignop(r.Type(), l.Type())
+ aop, _ = assignOp(r.Type(), l.Type())
if aop != ir.OXXX {
if l.Type().IsInterface() && !r.Type().IsInterface() && !types.IsComparable(r.Type()) {
base.Errorf("invalid operation: %v (operator %v not defined on %s)", n, op, typekind(r.Type()))
@@ -352,7 +352,7 @@ func tcConv(n *ir.ConvExpr) ir.Node {
n.SetType(nil)
return n
}
- op, why := Convertop(n.X.Op() == ir.OLITERAL, t, n.Type())
+ op, why := convertOp(n.X.Op() == ir.OLITERAL, t, n.Type())
if op == ir.OXXX {
// Due to //go:nointerface, we may be stricter than types2 here (#63333).
base.ErrorfAt(n.Pos(), errors.InvalidConversion, "cannot convert %L to type %v%s", n.X, n.Type(), why)
diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go
index 8642e0d14d..e54d5256e6 100644
--- a/src/cmd/compile/internal/typecheck/stmt.go
+++ b/src/cmd/compile/internal/typecheck/stmt.go
@@ -600,8 +600,8 @@ func tcSwitchExpr(n *ir.SwitchStmt) {
} else if t.IsInterface() && !n1.Type().IsInterface() && !types.IsComparable(n1.Type()) {
base.ErrorfAt(ncase.Pos(), errors.UndefinedOp, "invalid case %L in switch (incomparable type)", n1)
} else {
- op1, _ := Assignop(n1.Type(), t)
- op2, _ := Assignop(t, n1.Type())
+ op1, _ := assignOp(n1.Type(), t)
+ op2, _ := assignOp(t, n1.Type())
if op1 == ir.OXXX && op2 == ir.OXXX {
if n.Tag != nil {
base.ErrorfAt(ncase.Pos(), errors.MismatchedTypes, "invalid case %v in switch on %v (mismatched types %v and %v)", n1, n.Tag, n1.Type(), t)
diff --git a/src/cmd/compile/internal/typecheck/subr.go b/src/cmd/compile/internal/typecheck/subr.go
index 6cc93c45fb..d64b0f0e22 100644
--- a/src/cmd/compile/internal/typecheck/subr.go
+++ b/src/cmd/compile/internal/typecheck/subr.go
@@ -237,7 +237,7 @@ func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node {
return n
}
- op, why := Assignop(n.Type(), t)
+ op, why := assignOp(n.Type(), t)
if op == ir.OXXX {
base.Errorf("cannot use %L as type %v in %s%s", n, t, context(), why)
op = ir.OCONV
@@ -253,7 +253,7 @@ func assignconvfn(n ir.Node, t *types.Type, context func() string) ir.Node {
// If so, return op code to use in conversion.
// If not, return OXXX. In this case, the string return parameter may
// hold a reason why. In all other cases, it'll be the empty string.
-func Assignop(src, dst *types.Type) (ir.Op, string) {
+func assignOp(src, dst *types.Type) (ir.Op, string) {
if src == dst {
return ir.OCONVNOP, ""
}
@@ -265,10 +265,7 @@ func Assignop(src, dst *types.Type) (ir.Op, string) {
if types.Identical(src, dst) {
return ir.OCONVNOP, ""
}
- return Assignop1(src, dst)
-}
-func Assignop1(src, dst *types.Type) (ir.Op, string) {
// 2. src and dst have identical underlying types and
// a. either src or dst is not a named type, or
// b. both are empty interface types, or
@@ -367,7 +364,7 @@ func Assignop1(src, dst *types.Type) (ir.Op, string) {
// If not, return OXXX. In this case, the string return parameter may
// hold a reason why. In all other cases, it'll be the empty string.
// srcConstant indicates whether the value of type src is a constant.
-func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
+func convertOp(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
if src == dst {
return ir.OCONVNOP, ""
}
@@ -390,7 +387,7 @@ func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string) {
}
// 1. src can be assigned to dst.
- op, why := Assignop(src, dst)
+ op, why := assignOp(src, dst)
if op != ir.OXXX {
return op, why
}
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index 74dc09fdb6..b22e45358e 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -1209,7 +1209,7 @@ func checkassignto(src *types.Type, dst ir.Node) {
return
}
- if op, why := Assignop(src, dst.Type()); op == ir.OXXX {
+ if op, why := assignOp(src, dst.Type()); op == ir.OXXX {
base.Errorf("cannot assign %v to %L in multiple assignment%s", src, dst, why)
return
}