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
[SR-6996] Better diagnostic when declaring a class with parentheses #49544
Comments
Seems reasonable. @rintaro, think this would make a good starter bug? |
Yeah, this is good For those who want to tackle this task: Add another branch like: if (Tok.is(tok::colon)) {
...
} else if (Tok.is(tok::l_paren)) {
// if the following tokens looks like a type and followed by ')',
// treat it as Python style inheritance clause.
// Offer a fix-it to replace '(' with ': ' and remove ')'.
} |
Comment by Ryosuke Iwanaga (JIRA) I'm going to tackle this. |
Comment by Kazutaka Homma (JIRA) riywo (JIRA User) I've been working on this since a few days ago |
Comment by Ryosuke Iwanaga (JIRA) Got it, I gave up. |
Comment by Kazutaka Homma (JIRA) riywo (JIRA User) I think you could work on a task with no assignee. |
Comment by Kazutaka Homma (JIRA) I'm thinking that I should define a new Error message in DiagnosticsParse.def for this specific case. What I came up with so far is the following message. "expected ':' before inheritance identifier" However, I'm not sure this is the best. Is there any better idea? |
Comment by Kazutaka Homma (JIRA) Merged |
Additional Detail from JIRA
md5: 4a7df1509b4bcd5ea816866a6676cef6
Issue Description:
Switching between Python and Swift, I accidentally wrote: class Foo() { ... }
This generated a handful of diagnostics on one line, including:
Closure expression is unused (Did you mean to use a 'do' statement?)
Expecting '{' in class
Expressions are not allowed at the top level
Top-level statement cannot begin with a closure expression
Xcode decides to show the "closure expression" diagnostic instead of the second one, which is the closest to being to right thing to show. But it might be nice to have a special diagnostic for this.
The text was updated successfully, but these errors were encountered: