]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't emit conversion error in non-numeric increment/decrement
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 5 Mar 2016 20:36:56 +0000 (17:36 -0300)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 7 Mar 2016 14:34:58 +0000 (14:34 +0000)
commitc97ddf9c108adf0ca9c1aa2043a417885db411c2
tree34da500aa59b228e459f22878bdee931cc5011c3
parented8116989d84ba50f16cf7a88b5c0a44aa650087
cmd/compile: don't emit conversion error in non-numeric increment/decrement

In increment and decrement statements, explicit check that the type
of operand is numeric earlier. This avoids a related but less clear
error about converting "1" to be emitted.

So, when compiling

package main

func main() {
var x bool
x++
}

instead of emitting two errors

prog.go:5: cannot convert 1 to type bool
prog.go:5: invalid operation: x++ (non-numeric type bool)

just emits the second error.

Fixes #12525.

Change-Id: I6e81330703765bef0d6eb6c57098c1336af7c799
Reviewed-on: https://go-review.googlesource.com/20245
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue12525.go [new file with mode: 0644]