]> Cypherpunks repositories - gostls13.git/commit
go/types: don't accept incorrect shift expression arguments
authorgriesemer <gri@golang.org>
Fri, 22 Sep 2017 14:24:25 +0000 (16:24 +0200)
committerRobert Griesemer <gri@golang.org>
Mon, 25 Sep 2017 08:54:28 +0000 (08:54 +0000)
commit45395b5ad6d59f418cbe8b93950c9bae6e6f2196
tree675568ecc26a3ed49004ddbe8d71e2858ea90978
parent6945c67e102da9a37725de590b7e825d880ac848
go/types: don't accept incorrect shift expression arguments

Under certain circumstances involving shifts, go/types didn't verify
that untyped constant values were representable by the relevant type,
leading to the acceptance of incorrect programs (see the issue).

Fixing this code exposed another problem with int-to-string conversions
which suddenly failed because now the type-checker complained that a
(constant) integer argument wasn't representable as a string. Fixed that
as well.

Added many additional tests covering the various scenarious.

Found two cmd/compile bugs in the process (#21979, #21981) and filed
a go/types TODO (#21982).

Fixes #21727.

Change-Id: If443ee0230979cd7d45d2fc669e623648caa70da
Reviewed-on: https://go-review.googlesource.com/65370
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/api_test.go
src/go/types/conversions.go
src/go/types/expr.go
src/go/types/testdata/shifts.src