https://github.com/golang/go/issues/20824


On Tuesday, June 27, 2017 at 10:34:19 PM UTC-4, Jon Bodner wrote:
>
> Hi Ian,
>
> I'll file the bug report. Thanks for explaining how wrapper methods work. 
> I have a second test case with a pointer (and a successful attempt to 
> multiply a string by 2):
>
> https://play.golang.org/p/Dq9Y8DAkvA
>
> Thanks,
>
> Jon
>
> On Tuesday, June 27, 2017 at 5:01:05 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Tue, Jun 27, 2017 at 11:06 AM, Jon Bodner <[email protected]> 
>> wrote: 
>> > 
>> > I was writing up an example to demonstrate that embedded fields in a 
>> > dynamically generated struct don't delegate. Except that I somehow made 
>> one 
>> > that did: 
>> > 
>> > https://play.golang.org/p/TWApy-JibG 
>> > 
>> > What's extra-odd is that the behavior is completely wrong; it's 
>> doubling off 
>> > of the wrong field. 
>> > 
>> > Any idea what's going on? https://github.com/golang/go/issues/15924 
>> states 
>> > that this shouldn't have happened. 
>>
>> Hmmm, that's fairly bad.  Please file a bug report at 
>> https://golang.org/issue .  Thanks. 
>>
>> Issue 15924 is carefully worded.  reflect.StructOf does not generate 
>> wrapper methods for embedded fields.  But for an embedded field which 
>> is not a pointer and is the first field of the struct, you don't 
>> actually need a wrapper method.  StructOf does keep those methods 
>> around on the newly generated type.  But an embedded non-pointer that 
>> is not the first field does require a wrapper, and it looks like not 
>> only is StructOf not generating those wrappers, it is keeping the 
>> original method which then winds up using the data at the wrong 
>> offset.  At least, that is my first impression. 
>>
>> Ian 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to