diff options
author | Damian Gryski <[email protected]> | 2023-06-01 10:41:36 -0700 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-06-09 17:30:02 +0200 |
commit | f5f4751088bd40a8680899eefeb9854c8dbf4b33 (patch) | |
tree | b7a20ff88c6f31d368fcc783a6a92fa81021ab33 /testdata/interface.go | |
parent | 62fb386d57a0080881c756000e42a2c873372eb8 (diff) | |
download | tinygo-f5f4751088bd40a8680899eefeb9854c8dbf4b33.tar.gz tinygo-f5f4751088bd40a8680899eefeb9854c8dbf4b33.zip |
compiler,transform: fix for pointer-to-pointer type switches from @aykevl
Diffstat (limited to 'testdata/interface.go')
-rw-r--r-- | testdata/interface.go | 22 |
1 files changed, 22 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??") + } +} |