-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
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}
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis