mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lex a backtick-enclosed `[:identifier_start:][:identifier_cont:]+` as an identifier, even if it's a Swift keyword. For now, require that the escaped name still be a valid identifier, keyword collisions notwithstanding. (We could in theory allow an arbitrary string, but we'd have to invent a mangling for non-identifier characters and do other tooling which doesn't seem productive.) Swift SVN r14671
24 lines
656 B
Swift
24 lines
656 B
Swift
// RUN: %swift -parse -verify %s
|
|
|
|
func `protocol`() {}
|
|
|
|
`protocol`()
|
|
|
|
class `Type` {}
|
|
|
|
var `class` = `Type`.self
|
|
|
|
`class = `Type`.self // expected-error{{escaped identifier does not have a closing '`'}}
|
|
|
|
`class` = `Type // expected-error{{escaped identifier does not have a closing '`'}}
|
|
.type
|
|
|
|
let `0` = 0 // expected-error{{escaped identifier does not begin with a valid identifier start character}} expected-error{{expected pattern}}
|
|
let `foo-bar` = 0 // expected-error{{escaped identifier contains invalid identifier character}} expected-error{{expected pattern}}
|
|
|
|
func foo() {}
|
|
|
|
`foo`()
|
|
|
|
``() // expected-error{{escaped identifier cannot be empty}}
|