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-10295] Unexpected ambiguity error when trying to use variable with the same name as an instance member #52695

Open
xedin opened this issue Apr 3, 2019 · 3 comments
Assignees
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

@xedin
Copy link
Member

xedin commented Apr 3, 2019

Previous ID SR-10295
Radar rdar://problem/45572606
Original Reporter @xedin
Type Bug
Status In Progress
Resolution
Additional Detail from JIRA
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)`

@theblixguy
Copy link
Collaborator

I actually have a fix for this, which does not require a new diagnostic/fix: #23695.

@theblixguy
Copy link
Collaborator

Let me know if you have any suggestions @xedin!

@theblixguy
Copy link
Collaborator

I have assigned this to myself because I already have a PR in review to fix this: #23695

@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