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
swift-ci opened this issue
Feb 25, 2016
· 5 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfSILGenArea → compiler: The SIL generation stage
... so the return type of flatMap must be [Int?] to match the type of a, that implies T is Int?. That means the return type of transform must be Int??. Our closure returning Int? is properly accepted as it is covariant [0]. However, my expectation is that if our closure returns .None it would be treated as .Some(.None) ultimately by the transform, since .None is a valid Int? for wrapping in Int??.
[0]: Indeed, this code does not compile in 2.0, before closure covariance support was added.
The text was updated successfully, but these errors were encountered:
We expected lifting .None into a further optional context to yield .Some(.None), but it yields .None.
I ran this code in a playground in the Xcode version listed above.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfSILGenArea → compiler: The SIL generation stage
Environment
Swift 2.1, OS X 10.11.3, Xcode 7.2.1
Additional Detail from JIRA
md5: 3071c4e2e97357f55bc638d6b46d38eb
Issue Description:
Given the following snippet:
I expect the return value to be
[1,2,nil]
, but it returns[1,2]
instead.My rationale is that the matching function is...
... so the return type of
flatMap
must be[Int?]
to match the type ofa
, that impliesT
isInt?
. That means the return type oftransform
must beInt??
. Our closure returningInt?
is properly accepted as it is covariant [0]. However, my expectation is that if our closure returns.None
it would be treated as.Some(.None)
ultimately by thetransform
, since.None
is a validInt?
for wrapping inInt??
.[0]: Indeed, this code does not compile in 2.0, before closure covariance support was added.
The text was updated successfully, but these errors were encountered: