aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-01-17 15:12:17 +0100
committerAyke van Laethem <[email protected]>2024-01-18 19:51:52 +0100
commit0ad15551c84c39d53a9aef1c20c9e9ed8c9e1110 (patch)
tree45e27a28a0b3231a0ea6d702f6477cda3de3d1f0 /testdata
parentafd65e224af2442563ed79cc0c7f73fdc699e063 (diff)
downloadtinygo-0ad15551c84c39d53a9aef1c20c9e9ed8c9e1110.tar.gz
tinygo-0ad15551c84c39d53a9aef1c20c9e9ed8c9e1110.zip
compiler: update golang.org/x/tools/go/ssa package
This update includes support for the new range loops over integers.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/go1.22.go33
-rw-r--r--testdata/go1.22.txt12
2 files changed, 45 insertions, 0 deletions
diff --git a/testdata/go1.22.go b/testdata/go1.22.go
new file mode 100644
index 000000000..2b02a18e1
--- /dev/null
+++ b/testdata/go1.22.go
@@ -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")
+ }
+}
diff --git a/testdata/go1.22.txt b/testdata/go1.22.txt
new file mode 100644
index 000000000..2695c7846
--- /dev/null
+++ b/testdata/go1.22.txt
@@ -0,0 +1,12 @@
+10
+9
+8
+7
+6
+5
+4
+3
+2
+1
+go1.22 has lift-off!
+behaves like Go 1.21