You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: generics cannot infer slice/array of slice/array types #68262
Explicitly spoon feeding the compiler with the types will succeed in building the code, so it seems it's not a misuse of generics, simply a bug in the compiler's inference system:
commonArrayLengths does not have a core type. So type inference does not proceed to unify T with [][32]byte. So U is not inferred to be [32]byte. This is the observed error message. So this is not a bug. It is possible this could be supported in the future, but it is not supported at the moment.
Fixing this requires a change to the unification algorithm to proceed in some cases without a core type. I suspect this requires a proposal too.
Activity
gabyhelp commentedon Jul 1, 2024
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
thanm commentedon Jul 1, 2024
@golang/compiler
[-]cmd/compiler: generics cannot infer slice/array of slice/array types[/-][+]cmd/compile: generics cannot infer slice/array of slice/array types[/+]timothy-king commentedon Jul 2, 2024
commonArrayLengthsdoes not have a core type. So type inference does not proceed to unifyTwith[][32]byte. SoUis not inferred to be[32]byte. This is the observed error message. So this is not a bug. It is possible this could be supported in the future, but it is not supported at the moment.Fixing this requires a change to the unification algorithm to proceed in some cases without a core type. I suspect this requires a proposal too.
#63750 (comment) applies. Closing.