4 Commits

Author SHA1 Message Date
Daniel Martí e693cd0632 stabilize generic type param hashing for anonymous struct fields
Avoid hashing free type parameters by object/name identity in type
hashing and use traversal-local canonical IDs instead.
This keeps obfuscated field names stable across alpha-renamed generic
signatures (e.g. T vs newT), fixing interface/method mismatches.

The added test case fails without the fix:

    > exec garble build
    [stderr]
    # test/main
    YiaBFlNH.go:48: cannot use bT6psGs5O (variable of type *QdwRyqV[aEqmF4M, zpotHfQdnNB]) as E_OKfdHoPH[zpotHfQdnNB] value in return statement: *QdwRyqV[aEqmF4M, zpotHfQdnNB] does not implement E_OKfdHoPH[zpotHfQdnNB] (wrong type for method Redirect)
    		have Redirect(struct{palTavb zpotHfQdnNB})
    		want Redirect(struct{g3N8A_R zpotHfQdnNB})

The fix is Paul's; this is rebased on an updated version of typeutil,
and the test is now part of typeparams.txtar and much smaller.

Fixes #991.

Co-authored-by: Paul Scheduikat <lu4p@pm.me>
2026-02-28 01:22:11 +01:00
Daniel Martí 6c956e00e5 re-bundle the latest version of typeutil.Hasher
And document how we do this and why.
2026-02-28 01:22:11 +01:00
Daniel Martí cb83c50b13 all: run gopls's modernize -fix
Except on reflect_abi_code.go, as that needs to be compatible
with older versions of Go given that we inject its code.
2025-02-22 15:05:23 +00:00
Daniel Martí 8ca3d0adcf bundle x/tools/go/types/typeutil.hash and modify it
See the two "NOTE" comments below. In summary:

* struct field tags are not hashed
* named types are hashed by name rather than by pointer

We are keeping an eye on https://go.dev/issue/69420 as well.
2025-01-18 05:51:03 +01:00