Xcode v8.0 beta 3 (8S174q)
Apple Swift version 3.0 (swiftlang-800.0.34.6 clang-800.0.33)
Xcode v7.3.1 (7D1014)
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
I've been caught off-guard by the value that's chosen by the compiler when inferring the type to assign to an enum value. This can be especially surprising because nil is shorthand for Optional.none.
For example, if I have this enum:
Because myCoverageA gets a value of .some(.all), you might expect the value of myCoverageB to be .some(.none), but in fact it is .none.
I think this would also come up in a double-Optional. For example:
I think it would be nice to have a compiler warning in ambiguous cases like this.
I wrote up a slightly more detailed example of this here: http://kelan.io/2016/type-inferior-ence/