compiler: update golang.org/x/tools/go/ssa package

This update includes support for the new range loops over integers.
This commit is contained in:
Ayke van Laethem
2024-01-17 15:12:17 +01:00
parent afd65e224a
commit 0ad15551c8
5 changed files with 61 additions and 7 deletions
+33
View File
@@ -0,0 +1,33 @@
package main
func main() {
testIntegerRange()
testLoopVar()
}
func testIntegerRange() {
for i := range 10 {
println(10 - i)
}
println("go1.22 has lift-off!")
}
func testLoopVar() {
var f func() int
for i := 0; i < 1; i++ {
if i == 0 {
f = func() int { return i }
}
}
// Prints 1 in Go 1.21, or 0 in Go 1.22.
// TODO: this still prints Go 1.21 even in Go 1.22. We probably need to
// specify the Go version somewhere.
n := f()
if n == 0 {
println("behaves like Go 1.22")
} else if n == 1 {
println("behaves like Go 1.21")
} else {
println("unknown behavior")
}
}
+12
View File
@@ -0,0 +1,12 @@
10
9
8
7
6
5
4
3
2
1
go1.22 has lift-off!
behaves like Go 1.21