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
$ cat test.swift
import Foundation
let value = NSNumber(value: 0.1)
let double = value as! Double
let float = value as! Float
print("\(float) \(double)")
$ DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swift -version
Apple Swift version 3.1 (swiftlang-802.0.53 clang-802.0.42)
Target: x86_64-apple-macosx10.9
$ DEVELOPER_DIR=/Applications/Xcode-Beta.app/Contents/Developer xcrun swift -version
Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9
$ DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swift ../test.swift
0.1 0.1
$ DEVELOPER_DIR=/Applications/Xcode-Beta.app/Contents/Developer xcrun swift -swift-version 3 test.swift
fatal error: Unable to bridge NSNumber to Float: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.43/src/swift/stdlib/public/SDK/Foundation/NSNumber.swift, line 449
Looking at NSNumber.swift I can see that it's failing because the bridging conversion now requires that the value be exactly representable as a Float, which is a silent breaking change that applies even when in Swift 3.2 mode.
The text was updated successfully, but these errors were encountered:
Swift 3.2 is source-compatible with Swift 3.1, but may still have some behavioral changes. It does seem unfortunate that this one affects relatively simple values like 0.1, though—maybe our check for "exactly" equal isn't the best one. @phausler?
Additional Detail from JIRA
md5: ad8e2cadad5a75d75681cc31a9473d72
is duplicated by:
Issue Description:
Looking at NSNumber.swift I can see that it's failing because the bridging conversion now requires that the value be exactly representable as a Float, which is a silent breaking change that applies even when in Swift 3.2 mode.
The text was updated successfully, but these errors were encountered: