compiler: fix crash on type assert on interfaces with no methods

This commit is contained in:
Damian Gryski
2023-11-04 10:14:08 -07:00
committed by Ron Evans
parent 2b215955ca
commit 777048cfa9
3 changed files with 28 additions and 12 deletions
+9
View File
@@ -116,6 +116,9 @@ func main() {
// check that pointer-to-pointer type switches work
ptrptrswitch()
// check that type asserts to interfaces with no methods work
emptyintfcrash()
}
func printItf(val interface{}) {
@@ -334,3 +337,9 @@ func identify(itf any) {
println("other type??")
}
}
func emptyintfcrash() {
if x, ok := any(5).(any); ok {
println("x is", x.(int))
}
}