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
SR-12998 Raw Value of literal String #file breaks enum with String Protocol
Issue Description:
Currently, the use of a magic literal (such as #file) as a raw value for an enum case:
enumFoo:String{case bar = #file
}
triggers an error: use of '#file' literal as raw value for enum case is not supported.
We should support use of a limited set of magic literals as raw values. The eligible literals would be #file, #filePath, #function, #line and #column since their raw value types can be used as the raw type for an enum:
enumFooString:String{case bar = #file // okay, #file is String which matches the raw type}enumFooInt:Int{case bar = #line // okay, #line is Int which matches the raw type}
#line and #column can be easily fetched from the SourceManager, and the same with #file and #filePath I believe. #function name can be fetched by moving getMagicFunctionName from SILGen into AST (as a method on DeclContext).
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 89b49aa4c8519ddc9542ad6e2571af4e
relates to:
Issue Description:
Currently, the use of a magic literal (such as
#file
) as a raw value for an enum case:triggers an error:
use of '#file' literal as raw value for enum case is not supported
.We should support use of a limited set of magic literals as raw values. The eligible literals would be
#file
,#filePath
,#function
,#line
and#column
since their raw value types can be used as the raw type for an enum:#line
and#column
can be easily fetched from theSourceManager
, and the same with#file
and#filePath
I believe.#function
name can be fetched by movinggetMagicFunctionName
from SILGen into AST (as a method on DeclContext).The text was updated successfully, but these errors were encountered: