Skip to content

[SR-10295] Unexpected ambiguity error when trying to use variable with the same name as an instance member #52695

@xedin

Description

@xedin
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)`

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions