Skip to content

go/types: types.CheckExpr returns error when 'FuncType' ast.Expr has TypeParams #65898

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

Closed
csgura opened this issue Feb 23, 2024 · 4 comments
Closed
Assignees
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@csgura
Copy link

csgura commented Feb 23, 2024

Go version

go1.22

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/gura/Library/Caches/go-build'
GOENV='/Users/gura/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/gura/go/pkg/mod'
GONOPROXY='*.uangel.com'
GONOSUMDB='*.uangel.com'
GOOS='darwin'
GOPATH='/Users/gura/go'
GOPRIVATE='*.uangel.com'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/gura/git/fp/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/mr/dvhjg7zd4l125pln73bqyr400000gp/T/go-build857521387=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

https://go.dev/play/p/ZPv6Er1H6K3

What did you see happen?

error 'undefined: A' is returned

What did you expect to see?

In Go version 1.21, there were no errors

@prattmic
Copy link
Member

cc @griesemer @findleyr

@prattmic prattmic modified the milestones: Backlog, Go1.23 Feb 23, 2024
@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 23, 2024
@griesemer
Copy link
Contributor

Hm, this does indeed look like a regression.
More compact reproducer (may be used a test case in fix): https://go.dev/play/p/XZWMNTkAOHo

@griesemer
Copy link
Contributor

This is actually working as intended; the fact that the code worked for 1.21 was a bug in 1.21 which was fixed by CL 544035.

Evaluating the function type expression in your code (line 16) requires that the type parameters (here A) are in scope. They are not in scope at the start of the function type, but certainly after the function type. You can make your example work by changing the position provided in line 16 to the end position (example). With that change, the example works and prints OK.

So not a release blocker and not a bug. Will close with a test case for future reference.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/567215 mentions this issue: go/types: added test case for Checker.CheckExpr

gopherbot pushed a commit that referenced this issue Feb 27, 2024
For #65898.

Change-Id: I495e53060ac56b88a551ccd9901f25bbce97c714
Reviewed-on: https://go-review.googlesource.com/c/go/+/567215
Reviewed-by: Alan Donovan <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
@golang golang locked and limited conversation to collaborators Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants