-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: errors involving aliased types should use the alias name #21866
Comments
A random drive-by thought; instead of using just the alias name, use some combination of the alias name and the underlying defined type. Taking your example:
🚲 -shedding welcomed on the format. Reason being, the error message is then clear that |
This is a known limitation of cmd/compile (and go/types), but I don't think we filed an issue, so thanks for that! Within cmd/compile, the way we implement
is having the There is a precedent within the compiler that Perhaps the easiest fix is to generalize those special cases to any kind of type aliases. |
Another (perhaps obvious) observation in support of @bcmills's proposal is consistency with documentation: package playground
import (
"github.com/myitcv/playground/internal/a"
)
type T = a.S
func Hello(s T) {
}
func Fail() {
Hello(5)
} fails to compile with the message:
But the
|
Change https://golang.org/cl/98476 mentions this issue: |
by including *types.Type in typeVal. Updates #21866 Fixes #24159 Change-Id: I2f8cac252d88d43e723124f2867b1410b7abab7b Reviewed-on: https://go-review.googlesource.com/98476 Run-TryBot: Kunpei Sakai <namusyaka@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
I'm interested in this problem, so I'm thinking about it. |
I agree this would be a "nice to have" but I don't think this is of particular high priority. I also think it's quite subtle to get right in general (requires complete understanding of type representation in compiler). |
This came up in golang-nuts. |
In https://golang.org/cl/63277, @ianlancetaylor notes:
Concretely: if the compiler reports a type error involving an alias, it should use the aliased name of the type rather than the underlying/canonical name.
That would allow us to use type aliases for a larger subset of C types (#13467) without producing overly-cryptic error messages for mismatched types.
The text was updated successfully, but these errors were encountered: