-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Proposal-Accepted
Milestone
Description
I was surprised to learn yesterday that it is legal to embed an alias type whose underlying type is not a defined type.
type strings = []string
type S struct { strings } // equivalent to 'strings []string'
var _ = new(S).strings
This is legal according to the spec; there is supposed to be no promotion of methods from the alias's underlying type.
And yet promotion does occur:
https://go.dev/play/p/_bJZeiZW-cW
package main
import "io"
type S struct{ A }
var _ = new(S).A
type A = struct{ io.Reader }
func main() {
if false {
new(S).Read(nil) // not a legal program
}
}
I expect go/types has the same issue.
Metadata
Metadata
Labels
DocumentationIssues describing a change to documentation.Issues describing a change to documentation.NeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Proposal-Accepted