mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 15:03:41 +00:00
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:
Vendored
+33
@@ -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")
|
||||
}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
10
|
||||
9
|
||||
8
|
||||
7
|
||||
6
|
||||
5
|
||||
4
|
||||
3
|
||||
2
|
||||
1
|
||||
go1.22 has lift-off!
|
||||
behaves like Go 1.21
|
||||
Reference in New Issue
Block a user