[SR-7655] Double(exactly:) and Float(exactly:) can throw fatal errors when called with Self from a protocol extension #50196
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Environment
Swift 4.1 on MacOS
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.4.0
Additional Detail from JIRA
md5: 14461ce54f485ab1b622a72123886a21
Issue Description:
I ran into some unexpected fatal errors writing code to convert between different number types.
A much simplified example to reproduce this:
The output is
If I move the same exact code into Float and Double extensions like this, rather than using the default implementation for protocol A:
it works perfectly.
If I extend Int, Int32, Int64 to conform to A, the protocol default impl works perfectly for them; the issue seems to just be with floating point types.
Since the error is coming from generated code I wasn't sure how to dig further into what exactly is going on inside Swift here, but it seems incorrect that the protocol default implementation with Self is doing something different.
Let me know what you think - thanks!
The text was updated successfully, but these errors were encountered: