-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types, types2: consider interpreting type X [P]T as generic type with missing constraint if P is not declared #56064
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
Comments
The argument is that it is more likely that type X[P] <some type literal> where |
This sounds reasonable to me. One concern is how to handle follow-on errors. E.g., I think ideally go/types would only report "P is undeclared" for the package below, though even today it also reports "cannot index a (variable of type X)". So it seems okay if we instead report a spurious "cannot use X without instantiation" error.
|
Change https://go.dev/cl/439476 mentions this issue: |
Change https://go.dev/cl/439559 mentions this issue: |
Per discussion on the CL, while it's not hard to interpret an array declaration with an undefined length identifier as a generic type declaration with a missing type constraint, the re-interpretation leads to incorrect population of the various type-checker maps used by tools. Instead, opt for a better error message about the invalid array length. |
…nstraint If a generic type declaration is missing a constraint, syntactically it is an array type declaration with an undefined array length. Mention the possibility of a missing constraint in the error message for the undefined array length. For #56064. For #55961. For #51145. Change-Id: Ic161aeda9ea44faa8aa3bf3e9d62b3b13a95d4c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/439559 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
…nstraint If a generic type declaration is missing a constraint, syntactically it is an array type declaration with an undefined array length. Mention the possibility of a missing constraint in the error message for the undefined array length. For golang#56064. For golang#55961. For golang#51145. Change-Id: Ic161aeda9ea44faa8aa3bf3e9d62b3b13a95d4c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/439559 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Griesemer <[email protected]>
See #55961 for back story.
The text was updated successfully, but these errors were encountered: