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-9575] Compiler ignores global function to view error message in some situations. #52022

Closed
YOCKOW opened this issue Dec 25, 2018 · 4 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 type checker Area → compiler: Semantic analysis

Comments

@YOCKOW
Copy link
Collaborator

YOCKOW commented Dec 25, 2018

Previous ID SR-9575
Radar None
Original Reporter @YOCKOW
Type Bug
Status Resolved
Resolution Duplicate
Environment
  • OS: macOS Mojave 10.14.2

  • Swift: 4.2.1, DEVELOPMENT-SNAPSHOT-2018-12-24-a

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

md5: 9cd4d9374d7d69c611b5739c793e91a6

duplicates:

  • SR-9096 If a variable shadows a function, the diagnostic when attempting to invoke the variable like a function should suggest to rename the variable or qualify the function

Issue Description:

Compiler views two error messages when the following code is compiled.

As we expect, the first error message indicates the ambiguity between the global function and the instance method, and its notes imply how to fix the code.

However, the second one doesn't. It would be better to use the same message with the first.

[Sample Code]

var i = 0
func foo(label:Int) {}

struct S {
  func foo(_ s:String) {}
  func withUnsafeBytes(_ s:String) {}

  func incorrectCaller() {
    foo(label:i)
    // error: use of 'foo' refers to instance method 'foo' rather than global function 'foo(label:)' in module 'main'
    // note: use 'main.' to reference the global function in module 'main'
    // note: 'foo(label:)' declared here ...
    
    withUnsafeBytes(of:&i) {_ in}
    // error: extra argument 'of' in call
  }
}

foo(label:i)
withUnsafeBytes(of:&i) {_ in}
@belkadan
Copy link
Contributor

belkadan commented Jan 7, 2019

cc @xedin

@xedin
Copy link
Member

xedin commented Jan 8, 2019

Thanks for the reduced example, @YOCKOW! This is a duplicate of SR-9096. I think this would be relatively easy to fix using new diagnostic framework I just couldn't get to that yet.

@YOCKOW
Copy link
Collaborator Author

YOCKOW commented Jan 9, 2019

@xedin
Thank you for your response.
I didn’t notice this is dup of SR-9096.

@xedin
Copy link
Member

xedin commented Jan 9, 2019

No problem! 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants