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-7205] Unified Symbol Resolution giving non-unique resolution of variables #49753

Closed
swift-ci opened this issue Mar 15, 2018 · 7 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7205
Radar rdar://problem/34701880
Original Reporter Khan (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

MacOS 10.13.2

Swift 4.0.3

Additional Detail from JIRA
Votes 0
Component/s Compiler, Source Tooling
Labels Bug, Parser
Assignee @rintaro
Priority Medium

md5: 13029f03cc6b31b8ec9542c47068e618

Issue Description:

SourceKit USRs are not unique within a file for variables, even in well-formed programs:

for x in [1, 2, 3] {
  print(x)
}

for x in [4, 5, 6] { // This `x` has the same USR as that on line 1 and 2
  print(x)
}

if true {
  let x = 42 // This `x` has the same USR as that on line 1 and 2
  print(x)
}

if let x = Int("42") { // This `x` has the same USR as that on line 1 and 2
  print(x)
}
@belkadan
Copy link
Contributor

Sounds like we are not correctly handling the local discriminators for top-level code. It's probably getting reset between each TopLevelCodeDecl chunk, which is understandable but wrong.

@belkadan
Copy link
Contributor

cc @rintaro

@benlangmuir
Copy link
Member

@belkadan This is not specific to top-level code. If you put that code in a function you get the same problem. It affects all local variables and top-level code variables in the same decl context with the same name+type.

@belkadan
Copy link
Contributor

We definitely provide different mangled names to local types. Are we not doing that for local variables too?

@rintaro
Copy link
Mannequin

rintaro mannequin commented Apr 25, 2018

@belkadan
Copy link
Contributor

Was that supposed to be a PR link? :-)

@rintaro
Copy link
Mannequin

rintaro mannequin commented May 7, 2018

Oops. Thank you Jordan 😉
#16130

@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 parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

3 participants