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
The Swift compiler emits a warning when a variable is inferred to have a type that is an empty enum like Never. An easy way to trigger this is by assigning the result of a function that returns Never to a variable:
letnever = fatalError() // warning: constant 'never' inferred to have type 'Never', which is an enum with no cases
However, the compiler also emits this warning for variables inferred to be Never?, but warning is not accurate in that case, because Never? is an enum with two cases, `some` and `none` (though of course, a valid of Never?.some is as impossible as a value of Never).
funcmakeOptionalNever() -> Never? {
returnnil
}
letoptionalNever = makeOptionalNever() // warning: constant 'optionalNever' inferred to have type 'Never?', which is an enum with no cases
The compiler does not emit the warning for variables inferred to be Never??:
Environment
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.6.0
macOS 10.14.5 Mojave
Swift 5.0.1 bundled with Xcode 10.2.1 (10E1001)
Issue is reproducible both in Xcode and with the
swift
CLI.Additional Detail from JIRA
md5: cdc218f85104802ae78791de0fee0ad7
Issue Description:
The Swift compiler emits a warning when a variable is inferred to have a type that is an empty enum like
Never
. An easy way to trigger this is by assigning the result of a function that returnsNever
to a variable:However, the compiler also emits this warning for variables inferred to be
Never?
, but warning is not accurate in that case, becauseNever?
is an enum with two cases, `some` and `none` (though of course, a valid ofNever?.some
is as impossible as a value ofNever
).The compiler does not emit the warning for variables inferred to be
Never??
:The text was updated successfully, but these errors were encountered: