-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
x/tools/gopls: type constraint discrepancy between go compiler and gopls #61609
Comments
I guess this is an issue in go/types. |
Based on the description, I suspect an issue with export/import. I will take a look with urgency. It would be good to fix this for v0.13.0. |
Confirmed. If I turn off export data, the problem goes away. |
So, the problem is that named type forwarding breaks the relationship between the builtin Note that Fixing this is a bit tricky, because there is no way to access or set the comparable bit explicitly in the This will require careful review, so won't make the v0.13.0 release. Moving to v0.13.1. |
Also meant to say: thanks for the careful issue report! It made tracking this down much easier. |
Thanks for providing the workaround |
1 similar comment
Thanks for providing the workaround |
Since this is relatively unlikely, and has a simple workaround, punting to gopls@v0.14.0. |
Working on Go project In VSCode, I noticed gopls reports a problem which is ok for the compiler.
I extracted a minimal example as follows:
Suppose we have a project with packages
foo
(filefoo.go
) andbar
(filebar.go
).The package
foo
exports type constraintA
:The package
bar
consumes the constraintA
asSince the constraint
A
"inherits" fromcomparable
, the expressiona == b
is well defined:T
is constrained byA
which is comparable, hence==
is available for values of typeT
. The compiler is happy with the code.But VSCode reports
a == b
as the problem:In editor,
Two observations:
type A comparable
is defined in the packagebar
, it's ok for gopls – it's an cross-package problemtype A = comparable
ie. as typedef (not "newtype") in packagefoo
, it's also okThe text was updated successfully, but these errors were encountered: