cmd/compile: fail to infer type with only one valid solution #50212
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I'm trying to make some sort of
Nullable
constraint which would indicate if that type can be set tonil
or not.Right now I'm only trying to detect pointers and slices.
One way to detect a pointer type (which works) is the following:
It can also be done with slice type:
However if I try to combine those into a
Nullable
constraint the type inference breaks forU
.https://go.dev/play/p/SbBJnOUeFVP?v=gotip
Providing the types
U
andT
explicitly works tho.What did you expect to see?
I'm expecting the compiler to properly infer
U
andT
types. As there are multiple options forT
but only one of them is valid, it should be able to try to deduceU
just like it does when using thePtr[T]
orSlice[T]
constraint.What did you see instead?
You should be able to reproduce this with the
go.dev/play
link provided above.The text was updated successfully, but these errors were encountered: