]> Cypherpunks repositories - gostls13.git/commit
go/types: make sure constants valid in integer operations are in integer form
authorRobert Griesemer <gri@golang.org>
Fri, 5 Feb 2016 23:23:47 +0000 (15:23 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 8 Feb 2016 18:05:04 +0000 (18:05 +0000)
commit33a9a98e4d5893699749f75334c651b2adcecfb9
tree20c05a5738435661e228a428cb8b77502a0533f0
parentfa5e5478c8791d644c3d7b07a73680f87eb5a43b
go/types: make sure constants valid in integer operations are in integer form

The operation where this manifested in a crash was % (only defined on integers).
However, the existing code was sloppy in that it didn't retain the integer form
after a value (e.g., 3.0) was accepted as representable in integer form (3 for
the example). We would have seen a crash in such cases for / as well except
that there was code to fix it for just that case.

Remove the special code for / and fix more generally by retaining the integer
form for all operations if applicable.

Fixes #14229.

Change-Id: I8bef769e6299839fade27c6e8b5ff29ad6521d0d
Reviewed-on: https://go-review.googlesource.com/19300
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/expr.go
src/go/types/testdata/issues.src