]> Cypherpunks repositories - gostls13.git/commit
go/types: don't emit conversion error in non-numeric increment/decrement
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 5 Mar 2016 18:57:17 +0000 (15:57 -0300)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 7 Mar 2016 20:53:49 +0000 (20:53 +0000)
commit133c26b158b7764dd128f02e2d64de798c198582
treea1f9ebaf7c18bd3454842bf06fb9d36e3dbf2a18
parenta03bdc3e6bea34abd5077205371e6fb9ef354481
go/types: don't emit conversion error in non-numeric increment/decrement

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

So, when checking

package main

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

instead of emitting the error

prog.go:5:2: cannot convert 1 (untyped int constant) to bool

emits

prog.go:5:2: invalid operation: x++ (non-numeric type bool).

Updates #12525.

Change-Id: I00aa6bd0bb23267a2fe10ea3f5a0b20bbf3552bc
Reviewed-on: https://go-review.googlesource.com/20244
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/go/types/stmt.go
src/go/types/testdata/stmt0.src