You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
typeTinterface {
Foo()
}
funccompute(eT) int {
v, ok:=e.(interface {
F() int
})
ifok {
returnv.F()
} else {
return0
}
}
The error seems to be that in order to type check x.(T), where x is of type S the type checker first checks that T implements S.
Since in the above snippet, v is only used if ok, it makes sense to allow the type assertion to fail.
12:27:40.434 [thread-4] ERROR viper.gobra.reporting.FileWriterReporter - Error at: <main.go:8:11> main.go:8:11:error: type error: type interface{ F } does not implement the interface T
The text was updated successfully, but these errors were encountered:
The following snippet fails in the type checker.
The error seems to be that in order to type check
x.(T)
, where x is of typeS
the type checker first checks thatT
implementsS
.Since in the above snippet,
v
is only used ifok
, it makes sense to allow the type assertion to fail.The text was updated successfully, but these errors were encountered: