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
Dante-Broggi opened this issue
Apr 24, 2019
· 1 comment
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
I would expect the following function to return `5` if called with `Int.self`, and `nil` otherwise.
It doesn't compile, because the rhs of `as?` is evaluated more like a declaration than the expression it is.
func foo<T>(_ ty:T.Type)->T?{letx:Any=5lety= x as?ty// error: Use of undeclared type 'ty'return y
}
I suppose this is on the border of being a language improvement, rather than a bug, due to the duration this has existed and the differences between declaration type references and expression type references, but I still believe this is a bug.
The text was updated successfully, but these errors were encountered:
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselffeatureA feature request or implementation
Environment
Xcode 10.2 default toolchain.
Additional Detail from JIRA
md5: 79c282ebc732fb0ff683f5330121a87a
Issue Description:
I would expect the following function to return `5` if called with `Int.self`, and `nil` otherwise.
It doesn't compile, because the rhs of `as?` is evaluated more like a declaration than the expression it is.
I suppose this is on the border of being a language improvement, rather than a bug, due to the duration this has existed and the differences between declaration type references and expression type references, but I still believe this is a bug.
The text was updated successfully, but these errors were encountered: