avoid panic when embedding a builtin alias

TypeName.Pkg is documented as:

    Pkg returns the package to which the object belongs.
    The result is nil for labels and objects in the Universe scope.

When a struct type embeds a builtin alias type, such as byte,
this would lead to a panic since we assumed we could use the Pkg method.

Fixes #798.
This commit is contained in:
Daniel Martí
2023-11-14 21:18:40 +00:00
committed by Paul Scheduikat
parent 6f0e46f80b
commit 4271bc45ae
2 changed files with 20 additions and 8 deletions

View File

@@ -244,6 +244,13 @@ var _ = embeddingAliasSameName{
Reader: nil,
}
type embeddingBuiltinAlias struct {
byte
}
var _ = embeddingBuiltinAlias{3}
var _ = embeddingBuiltinAlias{byte: 3}
-- external/external.go --
package external