WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Invalid deepcopy generation for pointers to map type aliases #1312

@norbertcyran

Description

@norbertcyran

With types like these:

type MapAlias map[string]string  // any map would work

type Foo struct {
  Bar *MapAlias
}

DeepCopyInto for Foo is generated with a type error:

...
*out = new(map[string]string)  // incompatible types - expected MapAlias, got map[string]string

while instead it should generate:

*out = new(MapAlias)

Looks like this line is the culprit:

c.Linef("*out = new(%s)", (&namingInfo{typeInfo: underlyingElem}).Syntax(c.pkg, c.importsList))

However, I'm not sure if the fix is as simple as replacing underlyingElem with pointerType.Elem(). I guess there was a reason why this line looks different than the previous if block

Similar to #586

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