Skip to content

Generics: Instantiation of the list of generic structs is generated w/out generics #416

Description

@vgarvardt

Generics support in the new version is great, but I've found an issue with the generated code for a list case: if you add a list type with generics then its instantiation in the generated code is missing generics definition.

The easiest way to reproduce the issue is to add

type GenericTest3List[A, B any, AP msgp.RTFor[A], BP msgp.RTFor[B]] []GenericTest3[A, B, AP, BP]

to the https://github.com/tinylib/msgp/blob/master/_generated/generics.go and generate the code - DecodeMsg and UnmarshalMsg are generated with the following instantiation code:

	if cap((*z)) >= int(zb0002) {
		(*z) = (*z)[:zb0002]
	} else {
		(*z) = make(GenericTest3List, zb0002)
	}

while it should be

	if cap((*z)) >= int(zb0002) {
		(*z) = (*z)[:zb0002]
	} else {
		(*z) = make(GenericTest3List[A, B, AP, BP], zb0002)
	}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions