-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
backticked identifiersFeature → identifiers: Backticked identifiers. Allows using reserved words as identifiersFeature → identifiers: Backticked identifiers. Allows using reserved words as identifiersbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmacro expansionsFeature → expressions: Macro expansion expressionsFeature → expressions: Macro expansion expressionsparserArea → compiler: The legacy C++ parserArea → compiler: The legacy C++ parserswift 5.9unexpected errorBug: Unexpected errorBug: Unexpected error
Description
Description
I was hoping keywords like case
could be used as expression macro names in an unescaped manner, like static functions and methods, but sadly that doesn't seem to be the case.
Steps to reproduce
extension Int {
static let `case` = 1
}
let _: Int = .case // ✅
@freestanding(expression)
public macro `case`(Int) -> Int = …
let _ = #case(42) // 🛑
let _ = #`case`(42) // ✅
Expected behavior
I expect #case(42)
to compile OK.
Environment
- Swift compiler version info
swift-driver version: 1.82.2 Apple Swift version 5.9 (swiftlang-5.9.0.114.6 clang-1500.0.27.1) Target: arm64-apple-macosx13.0
- Xcode version info
Xcode 15.0 Build version 15A5160n
Metadata
Metadata
Assignees
Labels
backticked identifiersFeature → identifiers: Backticked identifiers. Allows using reserved words as identifiersFeature → identifiers: Backticked identifiers. Allows using reserved words as identifiersbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfexpressionsFeature: expressionsFeature: expressionsidentifiersFeature: IdentifiersFeature: Identifiersmacro expansionsFeature → expressions: Macro expansion expressionsFeature → expressions: Macro expansion expressionsparserArea → compiler: The legacy C++ parserArea → compiler: The legacy C++ parserswift 5.9unexpected errorBug: Unexpected errorBug: Unexpected error