fix: canonicalize generic field objects for struct hashing

Use `types.Var.Origin()` when mapping and hashing struct fields so selector and
declaration sites share the same canonical field identity. This fixes build
failures for generic aliases and named types over those aliases.

Fixes #924
This commit is contained in:
Paul Scheduikat
2026-03-01 16:30:56 +01:00
committed by Daniel Martí
parent 1b6cc14d93
commit cb98b4daab
4 changed files with 32 additions and 14 deletions
+12
View File
@@ -16,6 +16,11 @@ func main() {
g2 := GenericGraph[*[]byte]{Content: new([]byte)}
g2.Edges = make([]GenericGraph[*[]byte], 1)
var ga genericAlias
ga.list = nil
var gan genericAliasNamed
gan.list = nil
}
func GenericFunc[GenericParamA, B any](x GenericParamA, y B) {}
@@ -66,3 +71,10 @@ func (w *AsyncResult[oldT, newT]) AsResult() Result[newT] {
}
func (w *AsyncResult[oldT, newT]) Redirect(struct {ret newT}) {}
type genericAlias = generic[int]
type generic[T any] struct {
list *T
}
type genericAliasNamed genericAlias