aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/expr.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2021-02-11 10:23:41 -0500
committerRobert Findley <rfindley@google.com>2021-02-13 00:40:18 +0000
commitb81efb7ec4348951211058cf4fdfc045c75255d6 (patch)
tree262b756be7647299688e37d153cefaa180eb570f /src/go/types/expr.go
parenta7e9b4b94804a1fbefc0c012ec510f4ee0837ffa (diff)
downloadgo-b81efb7ec4348951211058cf4fdfc045c75255d6.tar.gz
go-b81efb7ec4348951211058cf4fdfc045c75255d6.zip
[dev.regabi] go/types: add support for language version checking
This is a port of CL 289509 to go/types. It differs from that CL in codes added to errors, to fit the new factoring of check_test.go, and to allow go/types to import regexp in deps_test.go For #31793 Change-Id: Ia9e4c7f5aac1493001189184227c2ebc79a76e77 Reviewed-on: https://go-review.googlesource.com/c/go/+/291317 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/go/types/expr.go')
-rw-r--r--src/go/types/expr.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/go/types/expr.go b/src/go/types/expr.go
index 7f8aaed411..aec3172327 100644
--- a/src/go/types/expr.go
+++ b/src/go/types/expr.go
@@ -772,6 +772,10 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
check.invalidOp(y, _InvalidShiftCount, "shift count %s must be integer", y)
x.mode = invalid
return
+ } else if !isUnsigned(y.typ) && !check.allowVersion(check.pkg, 1, 13) {
+ check.invalidOp(y, _InvalidShiftCount, "signed shift count %s requires go1.13 or later", y)
+ x.mode = invalid
+ return
}
var yval constant.Value
@@ -1152,6 +1156,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
case *ast.BasicLit:
switch e.Kind {
case token.INT, token.FLOAT, token.IMAG:
+ check.langCompat(e)
// The max. mantissa precision for untyped numeric values
// is 512 bits, or 4048 bits for each of the two integer
// parts of a fraction for floating-point numbers that are