Skip to content

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

@vgarvardt

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)
	}

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