n.Type = nil
return
}
+ if n.Implicit && !okforarith[l.Type.Etype] {
+ Yyerror("invalid operation: %v (non-numeric type %v)", n, l.Type)
+ n.Type = nil
+ return
+ }
// TODO(marvin): Fix Node.EType type union.
op = Op(n.Etype)
} else {
if t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) {
defaultlit2(&l, &r, true)
- if n.Op == OASOP && n.Implicit {
- Yyerror("invalid operation: %v (non-numeric type %v)", n, l.Type)
- n.Type = nil
- return
- }
-
if Isinter(r.Type) == Isinter(l.Type) || aop == 0 {
Yyerror("invalid operation: %v (mismatched types %v and %v)", n, l.Type, r.Type)
n.Type = nil
--- /dev/null
+// errorcheck
+
+// Copyright 2016 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Issue 12525: confusing error trying to increment boolean value
+
+package main
+
+func main() {
+ var i int
+ i++
+
+ var f float64
+ f++
+
+ var c complex128
+ c++
+
+ var b bool
+ b++ // ERROR "invalid operation: b\+\+ \(non-numeric type bool\)"
+
+ var s string
+ s-- // ERROR "invalid operation: s-- \(non-numeric type string\)"
+}