swiftlang/swift
View on GitHub[SR-10295] Unexpected ambiguity error when trying to use variable with the same name as an instance member
Open
#52,695 opened on Apr 3, 2019
bugcompilerdiagnostics qualitygood first issue
Description
| Previous ID | SR-10295 |
| Radar | rdar://problem/45572606 |
| Original Reporter | @xedin |
| Type | Bug |
| Status | In Progress |
| Resolution |
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, DiagnosticsQoI, StarterBug |
| Assignee | @theblixguy |
| Priority | Medium |
md5: 350070c7174a52610d975e704164ed3e
relates to:
- SR-1846 "Variable used in its own initial value" error when using a function (not a variable) of the same name
Issue Description:
Consider following example:
struct S {
func foo(x: Int) {}
func bar() {
let foo = foo(x: 42)
}
}
It produces following error:
variable used within its own initial value
Which doesn't really make much sense, instead it should produce an error which suggests to add `self.` before method or variable use e.g. `let foo = self.foo(x: 42)`