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

go/types: Scope.Innermost is incorrect for type parameters #64295

Closed
adonovan opened this issue Nov 20, 2023 · 3 comments
Closed

go/types: Scope.Innermost is incorrect for type parameters #64295

adonovan opened this issue Nov 20, 2023 · 3 comments
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@adonovan
Copy link
Member

Scope.Innermost should return the innermost lexical environment block (Scope) for an identifier, but it returns the wrong answer for references to type parameters outside the function body, because the position of the type parameter is not in the pos-end range of the function body scope.

This problem is not a blocker for gopls, only a problem for the test case in https://go.dev/cl/544035.
The fix for this issue will allow us to remove the "continue if name is U" statement.

@griesemer griesemer added this to the Go1.22 milestone Nov 27, 2023
@griesemer
Copy link
Contributor

Marking for 1.22 for visibility, in case we get to it. Not a release blocker.

@adonovan
Copy link
Member Author

I discovered in the course of fixing #64292 that the test wasn't executing anything at all (because of a missing ParseComments mode flag), and once that was fixed, this issue became an immediate blocker for the test in that CL, which now fixes both issues.

@adonovan adonovan assigned adonovan and unassigned griesemer and findleyr Nov 27, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/544035 mentions this issue: go/types: set correct Var.scopePos for parameters/results

@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 20, 2023
teddywing added a commit to teddywing/gocapturedrefrace that referenced this issue Mar 10, 2024
* Remove my debugging tests from trying to understand the Go 1.22
  problem.
* Describe the problem caused by the change in 'go/types' starting in Go
  1.22.0.

The problem was caused by
golang/go@a27a525,
which resolved the following two issues related to 'gopls':

* golang/go#64292
* golang/go#64295
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants