mirror of
https://github.com/golang/go
synced 2024-09-05 16:04:50 +00:00
spec: add another example for an invalid shift case
Fixes #45114. Change-Id: I969e5f1037254fc0ffbba2fc07a81a3987e6b05f Reviewed-on: https://go-review.googlesource.com/c/go/+/379275 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
50869f377f
commit
4042194f2d
|
@ -1,6 +1,6 @@
|
|||
<!--{
|
||||
"Title": "The Go Programming Language Specification - Go 1.18 Draft (incomplete)",
|
||||
"Subtitle": "Version of Jan 10, 2022",
|
||||
"Subtitle": "Version of Jan 18, 2022",
|
||||
"Path": "/ref/spec"
|
||||
}-->
|
||||
|
||||
|
@ -4259,7 +4259,8 @@ var p = 1<<s == 1<<33 // 1 has type int; p == true
|
|||
var u = 1.0<<s // illegal: 1.0 has type float64, cannot shift
|
||||
var u1 = 1.0<<s != 0 // illegal: 1.0 has type float64, cannot shift
|
||||
var u2 = 1<<s != 1.0 // illegal: 1 has type float64, cannot shift
|
||||
var v float32 = 1<<s // illegal: 1 has type float32, cannot shift
|
||||
var v1 float32 = 1<<s // illegal: 1 has type float32, cannot shift
|
||||
var v2 = string(1<<s) // illegal: 1 is converted to a string, cannot shift
|
||||
var w int64 = 1.0<<33 // 1.0<<33 is a constant shift expression; w == 1<<33
|
||||
var x = a[1.0<<s] // panics: 1.0 has type int, but 1<<33 overflows array bounds
|
||||
var b = make([]byte, 1.0<<s) // 1.0 has type int; len(b) == 1<<33
|
||||
|
|
Loading…
Reference in a new issue