]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: use compiler error message for undefined operators
authorRobert Griesemer <gri@golang.org>
Thu, 16 Dec 2021 18:50:34 +0000 (10:50 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 17 Dec 2021 00:14:53 +0000 (00:14 +0000)
For #48712.

Change-Id: I1596fe8688f093e0e92cf5b8d5501aac8631324e
Reviewed-on: https://go-review.googlesource.com/c/go/+/372894
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/types2/expr.go
src/go/types/expr.go

index 5961f32f37f58314b225d1809fdc2106c20806a9..3e3104abb65fb06a056ffe2d79cca0b993998e6e 100644 (file)
@@ -73,11 +73,7 @@ func init() {
 func (check *Checker) op(m opPredicates, x *operand, op syntax.Operator) bool {
        if pred := m[op]; pred != nil {
                if !pred(x.typ) {
-                       if check.conf.CompilerErrorMessages {
-                               check.errorf(x, invalidOp+"operator %s not defined on %s", op, x)
-                       } else {
-                               check.errorf(x, invalidOp+"operator %s not defined for %s", op, x)
-                       }
+                       check.errorf(x, invalidOp+"operator %s not defined on %s", op, x)
                        return false
                }
        } else {
@@ -790,11 +786,7 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator) {
                        if x.isNil() {
                                typ = y.typ
                        }
-                       if check.conf.CompilerErrorMessages {
-                               err = check.sprintf("operator %s not defined on %s", op, typ)
-                       } else {
-                               err = check.sprintf("operator %s not defined for %s", op, typ)
-                       }
+                       err = check.sprintf("operator %s not defined on %s", op, typ)
                }
        } else {
                err = check.sprintf("mismatched types %s and %s", x.typ, y.typ)
index 452e9ab598ab8651f7eab9763744c570176b3c50..8ddfb8de7e1b0caf1ae5ea57da5f45401af3ba64 100644 (file)
@@ -74,7 +74,7 @@ func init() {
 func (check *Checker) op(m opPredicates, x *operand, op token.Token) bool {
        if pred := m[op]; pred != nil {
                if !pred(x.typ) {
-                       check.invalidOp(x, _UndefinedOp, "operator %s not defined for %s", op, x)
+                       check.invalidOp(x, _UndefinedOp, "operator %s not defined on %s", op, x)
                        return false
                }
        } else {
@@ -745,7 +745,7 @@ func (check *Checker) comparison(x, y *operand, op token.Token) {
                        if x.isNil() {
                                typ = y.typ
                        }
-                       err = check.sprintf("operator %s not defined for %s", op, typ)
+                       err = check.sprintf("operator %s not defined on %s", op, typ)
                        code = _UndefinedOp
                }
        } else {