Skip to content
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-3254] Unhelpful diagnostics for compound name reference. #45842

Open
rintaro mannequin opened this issue Nov 22, 2016 · 9 comments
Open

[SR-3254] Unhelpful diagnostics for compound name reference. #45842

rintaro mannequin opened this issue Nov 22, 2016 · 9 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Nov 22, 2016

Previous ID SR-3254
Radar None
Original Reporter @rintaro
Type Bug
Environment

Swift version 3.0.1 (swift-3.0.1-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee None
Priority Medium

md5: fcfded4004226fb4776f82d7b6864fca

relates to:

  • SR-4867 func foo() {}; foo(_:) // Use of unresolved identifier 'foo'

Issue Description:

func foo(x: Int) {}
let f = foo(_:)

emits:

test.swift:2:9: error: use of unresolved identifier 'foo'
let f = foo(_:)
        ^~~~~~~
test.swift:1:6: note: did you mean 'foo'?
func foo(x: Int) {}
     ^

Because foo does exist. It should be something like:

test.swift:2:9: error: use of unresolved name 'foo(_:)'
let f = foo(_:)
        ^~~~~~~
test.swift:1:6: note: did you mean 'foo(x:)'?
func foo(x: Int) {}
     ^
@swift-ci
Copy link
Collaborator

Comment by Oscar Swanros (JIRA)

I'm trying to modify the DiagnosticsSema.def file for diag::note_typo_candidate to make it accept a DeclName instead of a StringRef so it can print the whole name as the suggestion.

However, after the change, the InFlightDiagnostic forwarding template for DiagnosticEngine is not accepting DeclName as a valid argument for any of the diagnose methods.

What else needs to be changed? @modocache CodaFi (JIRA User)

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 10, 2017

I'm not sure. Looking at the various specializations of InFlightDiagnostic::diagnose declared in include/swift/AST/DiagnosticEngine.h, it seems like it declares methods that take an ArrayRef<DiagnosticArgument>, and DiagnosticArgument in turn defines initializes that take a a single DeclName parameter. Based on my (very tenuous) grasp of C++, this seems like it'd work.

Can you post the compilation errors you're seeing? "Not accepting" is a little too vague for me to provide many more ideas.

@swift-ci
Copy link
Collaborator

Comment by Oscar Swanros (JIRA)

The specific error after changing the diag::note_typo_candidate note is a semantic issue: No matching member function for call to 'diagnose', at TypeChecker.h line 715.

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 10, 2017

If you could post the full output from your compilation to https://gist.github.com, that might make this easier. 🙂

My understanding is that what we're looking at here is that some class, probably DiagnosticEngine or InFlightDiagnostic or something, that doesn't have a diagnose method defined that responds to the arguments you're passing it. There are a bunch of methods named diagnose, however, so it's a little hard for me to tell just by reading the code which one is complaining... the full output from your compilation would help track it down!

@swift-ci
Copy link
Collaborator

Comment by Oscar Swanros (JIRA)

Ok, I figured it out.

Turns out that the issue was that there were other calls to diagnose with diag::note_typo_candidate as a parameter that were not passing the updated DeclName value, but a StringRef value still. Updating those calls to also pass a DeclName solved that issue.

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 10, 2017

Awesome! Keep posting any questions you have. Hopefully they help you reason about the failures as much as they help me learn about different parts of the Swift codebase. 🙂

@swift-ci
Copy link
Collaborator

Comment by Oscar Swanros (JIRA)

I've submitted an initial PR for this, awaiting general comments. Hopefully this is helpful!

#6715

@modocache
Copy link
Mannequin

modocache mannequin commented Jan 11, 2017

Great work!

@belkadan
Copy link
Contributor

Resetting assignee for all Starter Bugs not modified since 2018. If anyone wants to pick up swanros (JIRA User)'s PR they're welcome to!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants