compiler,transform: fix for pointer-to-pointer type switches from @aykevl

This commit is contained in:
Damian Gryski
2023-06-01 10:41:36 -07:00
committed by Ron Evans
parent 62fb386d57
commit f5f4751088
4 changed files with 44 additions and 6 deletions
+22
View File
@@ -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??")
}
}