Files
swift-mirror/test/Parse/escaped_identifiers.swift
Joe Groff 424187e482 Lexer: Lex escaped identifier tokens.
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
2014-03-05 03:47:12 +00:00

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}}