Skip to content

[Parse] Improve diagnostics for consecutive identifiers #7050

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

Merged
merged 1 commit into from
Feb 1, 2017

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jan 26, 2017

Improve and simplify diagnostics for consecutive identifiers.

We should diagnose this right after the first identifier parsing.
For type decls and enum 'case', in parseIdentifierDeclName().
For variable/constant names, in parsePattern() .

Previously, it used to emit superfluous diagnostics.
For instance:

let ABC DEF = 12
test.swift:2:1: error: expected expression

^
test.swift:1:5: error: type annotation missing in pattern
let ABC DEF = 12
    ^
class Foo Bar : Equatable { }
test.swift:1:15: error: expected '{' in class
class Foo Bar : Equatable { }
              ^
test.swift:1:27: error: statement cannot begin with a closure expression
class Foo Bar : Equatable { }
                          ^
test.swift:1:27: note: explicitly discard the result of the closure by assigning to '_'
class Foo Bar : Equatable { }
                          ^
                          _ = 
test.swift:1:27: error: braced block of statements is an unused closure
class Foo Bar : Equatable { }
                          ^
test.swift:1:27: error: expression resolves to an unused function
class Foo Bar : Equatable { }
                          ^~~

@rintaro
Copy link
Member Author

rintaro commented Jan 26, 2017

@swift-ci Please smoke test

@slavapestov slavapestov merged commit d880053 into swiftlang:master Feb 1, 2017
@rintaro rintaro deleted the parse-diag-consecutiveids branch February 2, 2017 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants