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
funcTestPanicTypeAssertSource(iinterface{}) {
s:=i.(core.Source)
_=s// The dominating type assertion would panic if i were not a source type.core.Sink(i) // TODO(210) want "a source has reached a sink"
}
Clearly, the only way that the call to core.Sink can be reached is if i holds a value of type core.Source. The above code is therefore unsafe.
The following case is more ambiguous, and currently we do not expect a report to be produced:
funcTestOkayTypeAssert(iinterface{}) {
s, ok:=i.(core.Source)
_, _=s, ok// The dominating type assertion will not panic.core.Sink(i)
}
Since the , ok form is used, it is possible that the type assertion failed and that i is in fact safe to sink. However, there is certainly a possibility that i contains a value of type core.Source, and therefore this code should perhaps be considered unsafe.
The text was updated successfully, but these errors were encountered:
This issue is related to #161.
Consider the following test case:
Clearly, the only way that the call to
core.Sink
can be reached is ifi
holds a value of typecore.Source
. The above code is therefore unsafe.The following case is more ambiguous, and currently we do not expect a report to be produced:
Since the
, ok
form is used, it is possible that the type assertion failed and thati
is in fact safe to sink. However, there is certainly a possibility thati
contains a value of typecore.Source
, and therefore this code should perhaps be considered unsafe.The text was updated successfully, but these errors were encountered: