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

cmd/compile: incorrect program produces "invalid syntax tree" error #58612

Open
griesemer opened this issue Feb 21, 2023 · 2 comments
Open

cmd/compile: incorrect program produces "invalid syntax tree" error #58612

griesemer opened this issue Feb 21, 2023 · 2 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

package main

func main() {
	var value = new(Demo)
	UseFunc[value.(type)]()
}

type Demo struct{}

func UseFunc[T any]() {}

produces 3 errors:

./prog.go:4:6: value declared and not used
./prog.go:5:10: value.(type) is not a type
./prog.go:5:10: invalid syntax tree: use of .(type) outside type switch

Only the 2nd error should be presented.

From #58608.

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 21, 2023
@griesemer griesemer added this to the Go1.21 milestone Feb 21, 2023
@griesemer griesemer self-assigned this Feb 21, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Feb 21, 2023
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/470015 mentions this issue: go/types, types2: avoid unused variable error in invalid x.(type) expression

@griesemer
Copy link
Contributor Author

griesemer commented Feb 21, 2023

The above CL reduces the number of follow-on errors to 1 (for 2 errors total). Good enough for now. Marking as backlog.

@griesemer griesemer modified the milestones: Go1.21, Backlog Feb 21, 2023
gopherbot pushed a commit that referenced this issue Feb 22, 2023
…ression

This change removes one of the two follow-on errors in the issue below.

For #58612.

Change-Id: If1eec5031e524bad33caa4a914f52e6a1e273b60
Reviewed-on: https://go-review.googlesource.com/c/go/+/470015
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
johanbrandhorst pushed a commit to Pryz/go that referenced this issue Feb 22, 2023
…ression

This change removes one of the two follow-on errors in the issue below.

For golang#58612.

Change-Id: If1eec5031e524bad33caa4a914f52e6a1e273b60
Reviewed-on: https://go-review.googlesource.com/c/go/+/470015
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
@mknyszek mknyszek moved this to In Progress in Go Compiler / Runtime Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: In Progress
Development

No branches or pull requests

2 participants