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/parser: composite lit fields resolve incorrectly #45160

findleyr opened this issue Mar 22, 2021 · 1 comment

go/parser: composite lit fields resolve incorrectly #45160

findleyr opened this issue Mar 22, 2021 · 1 comment


Copy link

@findleyr findleyr commented Mar 22, 2021

Resolving struct fields is a known limitation of go/parser object resolution. However, there is an additional bug that composite lit fields may be incorrectly resolved to unrelated declarations in the package scope. For example:

func _() {
  var tests = []dirLinkTest {
      mklink: func(link, target string) error { return nil },

func mklink() {}

The mklink field identifier will be incorrectly resolved to the mklink function (found in os/os_windows_test.go).

Upon investigating this bug, it seems that it is a known limitation:;l=1610;drc=0bd308ff27822378dc2db77d6dd0ad3c15ed2e08

Will be fixed as part of #45104.

CC @griesemer

@findleyr findleyr added the NeedsFix label Mar 22, 2021
@findleyr findleyr added this to the Backlog milestone Mar 22, 2021
@findleyr findleyr self-assigned this Mar 22, 2021
Copy link

@gopherbot gopherbot commented Mar 24, 2021

Change mentions this issue: go/parser: add data-driven tests for object resolution

gopherbot pushed a commit that referenced this issue Mar 30, 2021
Add new tests for object resolution driven by source files with
declarations and uses marked via special comments. This made it easier
to add test coverage while refactoring object resolution for #45104.

Tests are added to a new resolver_test.go file. In a subsequent CL the
resolver.go file will be added, making this choice of file name more

For #45104
For #45136
For #45160

Change-Id: I240fccc0de95aa8f2d03e39c77146d4c61f1ef9e
Trust: Robert Findley <>
Trust: Robert Griesemer <>
Run-TryBot: Robert Findley <>
Reviewed-by: Robert Griesemer <>
TryBot-Result: Go Bot <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants