1
0
mirror of https://github.com/golang/go synced 2024-09-29 04:24:36 -06:00
Commit Graph

1 Commits

Author SHA1 Message Date
Caio Marcelo de Oliveira Filho
c97ddf9c10 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>
2016-03-07 14:34:58 +00:00