aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorDamian Gryski <[email protected]>2023-06-01 10:41:36 -0700
committerRon Evans <[email protected]>2023-06-09 17:30:02 +0200
commitf5f4751088bd40a8680899eefeb9854c8dbf4b33 (patch)
treeb7a20ff88c6f31d368fcc783a6a92fa81021ab33 /testdata
parent62fb386d57a0080881c756000e42a2c873372eb8 (diff)
downloadtinygo-f5f4751088bd40a8680899eefeb9854c8dbf4b33.tar.gz
tinygo-f5f4751088bd40a8680899eefeb9854c8dbf4b33.zip
compiler,transform: fix for pointer-to-pointer type switches from @aykevl
Diffstat (limited to 'testdata')
-rw-r--r--testdata/interface.go22
-rw-r--r--testdata/interface.txt3
2 files changed, 25 insertions, 0 deletions
diff --git a/testdata/interface.go b/testdata/interface.go
index 7820538a4..72cc76bce 100644
--- a/testdata/interface.go
+++ b/testdata/interface.go
@@ -113,6 +113,9 @@ func main() {
println("slept 1ms")
blockStatic(SleepBlocker(time.Millisecond))
println("slept 1ms")
+
+ // check that pointer-to-pointer type switches work
+ ptrptrswitch()
}
func printItf(val interface{}) {
@@ -312,3 +315,22 @@ func namedptr2() interface{} {
type Test byte
return (*Test)(nil)
}
+
+func ptrptrswitch() {
+ identify(0)
+ identify(new(int))
+ identify(new(*int))
+}
+
+func identify(itf any) {
+ switch itf.(type) {
+ case int:
+ println("type is int")
+ case *int:
+ println("type is *int")
+ case **int:
+ println("type is **int")
+ default:
+ println("other type??")
+ }
+}
diff --git a/testdata/interface.txt b/testdata/interface.txt
index 04e3fb9ea..fec46637b 100644
--- a/testdata/interface.txt
+++ b/testdata/interface.txt
@@ -24,3 +24,6 @@ Byte(): 3
non-blocking call on sometimes-blocking interface
slept 1ms
slept 1ms
+type is int
+type is *int
+type is **int