Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread Paul Jolly
> That snippet is helpful, but given https://golang.org/issue/40965 I'm > concerned user defined aliases will suffer the same issue when it's > resolved. I would be very surprised if that affects Type() to be honest because that issue is about error message reporting, i.e. "unwinding" to actual

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread 'Dan Kortschak' via golang-nuts
On Fri, 2020-08-21 at 21:51 -0700, Ian Lance Taylor wrote: > > > Thanks, Ian. > > > > No that doesn't work. For example with type byte, you get back the > > byte > > name. > > > > https://play.golang.org/p/PPjHBotsIsw > > The underlying type of byte is indeed byte. What are you hoping for? >

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2020-08-22 at 06:00 +0100, Paul Jolly wrote: > I think you were unlucky with your choice of type to experiment with. > My understanding is that byte is special cased, despite being an > alias: > >

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread Paul Jolly
I think you were unlucky with your choice of type to experiment with. My understanding is that byte is special cased, despite being an alias: https://github.com/golang/go/blob/13e41bcde8c788224f4896503b56d42614e0bf97/src/go/types/universe.go#L25 Consider instead

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread Ian Lance Taylor
On Fri, Aug 21, 2020, 9:16 PM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Sat, 2020-08-15 at 21:44 -0700, Ian Lance Taylor wrote: > > On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts > > wrote: > > > > > > I would like to be able to obtain the

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-21 Thread 'Dan Kortschak' via golang-nuts
On Sat, 2020-08-15 at 21:44 -0700, Ian Lance Taylor wrote: > On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts > wrote: > > > > I would like to be able to obtain the original type for an alias > > given > > a source input. I can see in "go/types" that it's possible to know > >

Re: [go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-15 Thread Ian Lance Taylor
On Sat, Aug 15, 2020 at 3:45 PM 'Dan Kortschak' via golang-nuts wrote: > > I would like to be able to obtain the original type for an alias given > a source input. I can see in "go/types" that it's possible to know > whether a named type is an alias by `typ.Obj().IsAlias()`, but I cannot > see

[go-nuts] obtaining the original type from a named alias type with go/types?

2020-08-15 Thread 'Dan Kortschak' via golang-nuts
I would like to be able to obtain the original type for an alias given a source input. I can see in "go/types" that it's possible to know whether a named type is an alias by `typ.Obj().IsAlias()`, but I cannot see how to obtain the actual original type unless it is an alias for a basic type. Can