mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
compiler,transform: fix for pointer-to-pointer type switches from @aykevl
This commit is contained in:
Vendored
+22
@@ -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??")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user