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, types2: type-checking invalid IndexExprs should use their operands #60906

Closed
findleyr opened this issue Jun 20, 2023 · 1 comment
Closed
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@findleyr
Copy link
Contributor

func _() {
	var x int
	var f func() []int
	_ = f[x]
}

https://go.dev/play/p/ev4lDI7nxQ-

Outputs:

./prog.go:6:6: x declared and not used
./prog.go:8:7: invalid operation: cannot index f (variable of type func() []int)

But x is used. On go1.17 there is just one error: ./run.go:10:15: invalid operation: f[x] (type func() []int does not support indexing).

CC @griesemer

@findleyr findleyr added this to the Go1.22 milestone Jun 20, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/504877 mentions this issue: go/types, types2: avoid spurious "declared and not used" error

bradfitz pushed a commit to tailscale/go that referenced this issue Jul 15, 2023
Fixes golang#60906.

Change-Id: Iba117b36041f72a54ce82cc914f8fa3b07a6fb2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/504877
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 20, 2023
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

3 participants