-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsFixThe 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.
Milestone
Description
The current behavior of the new go/types.Alias.String method is to print the aliased type in a comment, but I'm not convinced it should. We don't do this for named types, and it undermines one of the main benefits of aliases, which is brevity. The alias name alone seems clear enough, as it's what appears in the source.
$ go build -o alias ./alias.go
$ ./alias
func([]int)
$ GODEBUG=gotypesalias=1 ./alias
func([]command-line-arguments.A /* = int */)
package main
import (
"fmt"
"log"
"os"
"golang.org/x/tools/go/packages"
)
type A = int
var x func([]A)
func main() {
cfg := &packages.Config{Mode: packages.LoadAllSyntax}
pkgs, err := packages.Load(cfg, "./alias.go")
if err != nil {
log.Fatal(err)
}
if packages.PrintErrors(pkgs) > 0 {
os.Exit(1)
}
fmt.Println(pkgs[0].Types.Scope().Lookup("x").Type())
}
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe 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.