mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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).
30 lines
842 B
Swift
30 lines
842 B
Swift
// 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}}
|