-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Display correct debug note for compound references typo suggestions #6715
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
@swift-ci Please smoke test |
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 looks pretty good to me! Just needs a few code style changes. Assuming the tests pass, I think this could be merged -- but I'll leave it to someone more familiar with this part of the codebase to approve the pull request.
@@ -555,13 +555,16 @@ void TypeChecker::performTypoCorrection(DeclContext *DC, DeclRefKind refKind, | |||
} | |||
|
|||
static InFlightDiagnostic | |||
diagnoseTypoCorrection(TypeChecker &tc, DeclNameLoc loc, ValueDecl *decl) { | |||
diagnoseTypoCorrection(TypeChecker &tc, DeclNameLoc loc, ValueDecl *decl, FunctionRefKind refKind) { |
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.
nit-pick: The style guide for C++ in Swift projects is a 80 character column width. You should format this like so:
diagnoseTypoCorrection(TypeChecker &tc,
DeclNameLoc loc,
ValueDecl *decl,
FunctionRefKind refKind) {
Same goes for the line of code below this one: you'll need to split it across two lines for it to fit within 80 characters.
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.
Oh, thanks! Will update accordingly.
@swift-ci please smoke test |
@modocache updated with code-style comments. Thanks for the eyes on this! |
ValueDecl *decl, | ||
FunctionRefKind refKind) { | ||
|
||
auto name = refKind == FunctionRefKind::Compound ? decl->getFullName() : |
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.
LLVM style moves the colon to a new line in-line with the else condition and aligns it with the question mark.
auto name = refKind == FunctionRefKind::Compound ? decl->getFullName()
: decl->getName();
// RUN: %target-typecheck-verify-swift | ||
|
||
func foo(x: Int) {} // expected-note * {{did you mean 'foo(x:)'?}} | ||
let f = foo(_:) // expected-error {{use of unresolved identifier 'foo'}} |
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.
Please remove this file and add these tests to Sema/typo_correction.swift
(sans * on the expected-note
).
@@ -555,13 +555,21 @@ void TypeChecker::performTypoCorrection(DeclContext *DC, DeclRefKind refKind, | |||
} | |||
|
|||
static InFlightDiagnostic | |||
diagnoseTypoCorrection(TypeChecker &tc, DeclNameLoc loc, ValueDecl *decl) { | |||
diagnoseTypoCorrection(TypeChecker &tc, | |||
DeclNameLoc loc, |
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.
You don't necessarily have to fold the entire signature over, just those that go over the line-limit. If it makes it easier, you can run clang-format
with the default LLVM style to have it wrap these for you.
@CodaFi Fixed your comments. Thanks! |
FunctionRefKind refKind) { | ||
|
||
auto name = refKind == FunctionRefKind::Compound ? decl->getFullName() | ||
: decl->getName(); |
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.
Here you must add the quotes back or it'll fall any existing typo correction tests that rely on it.
@@ -2083,7 +2083,8 @@ class TypeChecker final : public LazyResolver { | |||
unsigned maxResults = 4); | |||
|
|||
void noteTypoCorrection(DeclName name, DeclNameLoc nameLoc, | |||
const LookupResult::Result &suggestion); | |||
const LookupResult::Result &suggestion, | |||
FunctionRefKind refKind = FunctionRefKind::Unapplied); |
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.
I'm still not 100% sure this is the right type for this. For names that aren't function references that go through typo correction this is kind of nonsensical.
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.
Is there any other type that would work in this case?
@OscarSwanros What's the status of this pull request? If you're still interested in this bug fix, could you rebase this pull request and give me a ping? |
This patch has fallen behind after a month. @OscarSwanros feel free to reopen this when you find the time. |
Oh, sorry @CodaFi — have been swamped and missed your notification. Will try to find the time soon. |
This PR tries to address the issue where functions with multiple arguments would just be diagnosed incorrectly ignoring their attributes.
Resolves #45842.