Files
swift-mirror/test/Parse/identifiers.swift
Chris Lattner 0bfacde242 Fix: <rdar://problem/16230507> Cannot use a negative constant as the second operator of ... operator
This is a case that the operator splitting code didn't handle because of
the bizarre lexer code for handling operators with periods in them.  We had
accreted some weird special case logic for what is valid in an operator
(but which even had a special case hack for ..<).  The policy is now very
simple: if an operator name starts with a dot, it is allowed to include other
dots in its name.  If it doesn't, it doesn't.  This allows us to get lexer
level operator splitting in cases like x=.Foo, allowing our existing operator
set that have dots in them without hacks, and provides a superior QoI
experience due to operator splitting.

This is technically a language change, but the TSPL operator grammar was
incorrect for it anyway.  I will file an internal radar to get TSPL updated
with the actual behavior (now that it is defensible).
2015-12-16 22:16:19 -08:00

30 lines
842 B
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// RUN: %target-parse-verify-swift
func my_print<T>(t: T) {}
class {
class שלום {
class {
class Γειά {
class func привет() {
my_print("hello")
}
}
}
}
}
.שלום..Γειά.привет()
// Identifiers cannot start with combining chars.
_ = .́duh() // expected-error {{use of unresolved operator '.́'}} // expected-error{{use of unresolved identifier 'duh'}}
// Combining characters can be used within identifiers.
func s̈pin̈al_tap̈() {}
// Private-use characters aren't valid in Swift source.
() // expected-error{{invalid character in source file}} {{1-4= }}
// Placeholders are recognized as identifiers but with error.
func <#some name#>() {} // expected-error 2 {{editor placeholder in source file}}