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: less helpful error message for invalid array types #51145

Closed
Merovius opened this issue Feb 11, 2022 · 4 comments
Closed

cmd/compile: less helpful error message for invalid array types #51145

Merovius opened this issue Feb 11, 2022 · 4 comments
Labels
NeedsInvestigation
Milestone

Comments

@Merovius
Copy link

@Merovius Merovius commented Feb 11, 2022

Originally reported on golang-nuts.

It seems the go 1.18 type checker provides less helpful error messages in some cases of invalid array type declarations. For this declaration:

type A [float64]int

The go 1.17 compiler prints (playground link):

./prog.go:3:8: invalid array bound float64
./prog.go:3:9: type float64 is not an expression

While the go 1.18 compiler prints (playground link):

./prog.go:3:9: float64 (type) is not an expression

Note that it omits the "invalid array bound float64" message. This seems like a regression to me.

@KZiemian
Copy link

@KZiemian KZiemian commented Feb 11, 2022

Thank you @Merovius for taking initiative. I hesitated about posting it myself, because I guess that problem error message "invalid array bound float64" was possible, when compiler know that "[something]" means definition of array. But now it can also mean definition of type parameter and compiler can't/doesn't decide which case it is.

Of course, I may be wrong.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 11, 2022

CC @griesemer @findleyr

@ianlancetaylor ianlancetaylor added the NeedsInvestigation label Feb 11, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Feb 11, 2022
@griesemer griesemer self-assigned this Feb 11, 2022
@griesemer griesemer removed this from the Go1.19 milestone Feb 11, 2022
@griesemer griesemer added this to the Go1.18 milestone Feb 11, 2022
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 11, 2022

This happens to be trivial to fix and it is not invasive. CL forthcoming.

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 11, 2022

Change https://go.dev/cl/385255 mentions this issue: go/types, types2: better error message for invalid array length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

5 participants