runtime: new "types from different packages" messages is not always true #26094
Comments
We could always say "types from different scopes" as that would also apply to them being from different packages. |
Change https://golang.org/cl/123395 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
CL 116255 added an extra message to type assertion failures, so that under certain conditions they look like:
This confused me for a little while: I am working in golang.org/x/vgo/vendor/cmd/go/internal/modfetch and the only other modfetch that seemed plausible would be the cmd/go/internal/modfetch from the standard library. For a minute I wondered how the build could possibly have crossed the two package trees. But in fact in my crash the types in question are from the same package: the message is incorrect. I had originally declared the same type in two functions, and then when I realized one might leak into the other, I made a global, but I forgot to delete one of the function-scoped types.
Here is an equivalent reproduction case:
Can we do something in the check to detect types from the same package but different scopes and change the message to "types from different scopes"? I suppose we could fall back to "types from different scopes or packages" but it would be more helpful if the message can be precise (without being incorrect).
The global type T is unused in the test program, but you could delete either the one in F or the one in G and have a perhaps different test case also worth checking.
/cc @griesemer @randall77
The text was updated successfully, but these errors were encountered: