In the "Special situations" section of this article 
https://go.dev/blog/type-inference,
it is mentioned a bit on this.
My understanding of that chapter is, when choosing the inferred type 
argument,
the current priority is: name types > directional channel types > other 
unnamed types.

In the case of the current thread, there are two type argument candidates, 
both of
them are named types, so the type interference fails.

Maybe the priority should be: interface types > named types > directional 
channel types > other unnamed types.

On Tuesday, October 24, 2023 at 3:53:14 AM UTC+8 Mike Schinkel wrote:

> Yes, I was surprised too.  It actually took me the better part of a day 
> trying to get this to work before finally posting to the list.
>
> It turns out that this limit was actually documented by Ian Lance Taylor 
> back in February 2023:
>
> https://github.com/golang/go/issues/58650
>
> Look for the section entitled *"Inferring based on interfaces."*
>
> Again, it sure would be nice it this were possible, if for no other reason 
> than to keep others being as time-inefficient as I was while trying to 
> figure it out. 
>
> -Mike
> On Sunday, October 22, 2023 at 11:01:47 PM UTC-4 tapi...@gmail.com wrote:
>
>> On Monday, October 23, 2023 at 10:38:59 AM UTC+8 tapi...@gmail.com wrote:
>>
>> Sorry, I didn't look your full code.
>> I think the full code should work with Go toolchain 1.21.n.
>>
>>
>> Aha, it actually doesn't. I'm surprised.
>>
>>
>> On Sunday, October 22, 2023 at 4:40:55 PM UTC+8 Mike Schinkel wrote:
>>
>> How so? 
>>
>> Can you give an example scenario where it could cause unintended 
>> consequences?  Or some other negative?
>>
>> -Mike
>>
>> On Saturday, October 21, 2023 at 11:57:52 PM UTC-4 tapi...@gmail.com 
>> wrote:
>>
>>
>> It is hard to call such type inference better. That is too aggressive.
>>
>>

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ee59d818-9219-44b3-9841-51e67037a02dn%40googlegroups.com.

Reply via email to