-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Lexer] Disallow '$' as a start of identifier, special handle '$'
#6004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Ping, could someone please review this? let `$0` = "FOO"
let foo: (Int) -> Void = {
print($0, `$0`)
}hits assertion. |
|
Sorry about that, meant to approve this weeks ago. Thanks for fixing this. @swift-ci please smoke test. |
|
No worries. Thanks @CodaFi ! Oops. It seems, somehow, I forgot to add testcases 👎 . I will. |
2797692 to
040f9e8
Compare
Allowing 'let `$0` = 1', introduced in 6accc59 was not intentional.
040f9e8 to
7819d0e
Compare
| // FIXME: Bad diagnostics. | ||
| `$0` = 1 // expected-error {{expected expression}} | ||
| `$$` = 2 // expected-error {{expected numeric value following '$'}} | ||
| `$abc` = 3 // expected-error {{expected numeric value following '$'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the Swift3 behavior. Diagnostics doesn't look nice.
We can improve this, but not for now.
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test |
I believe, accepting
`$0`as an identifier was not intentional. It was not allowed in Swift2/3.0This behavior was introduced in #5270 which intended to allow
`$`as an identifier.I think, we shouldn't generally consider
$as a valid start character for identifiers.Instead, handle
`$`specially.