Re: [go-nuts] Strange behavior of range over composite literal.

2018-10-08 Thread Raffaele Sena
Thanks for the answers. I tried to read the specs, but didn't go as far as the parsing ambiguity section :( -- Raffaele On Mon, Oct 8, 2018 at 12:20 PM Ian Lance Taylor wrote: > On Mon, Oct 8, 2018 at 12:10 PM, Raffaele Sena wrote: > > > > I found a strange behavior (well, I would call it a bu

Re: [go-nuts] Strange behavior of range over composite literal.

2018-10-08 Thread Ian Lance Taylor
On Mon, Oct 8, 2018 at 12:10 PM, Raffaele Sena wrote: > > I found a strange behavior (well, I would call it a bug) of for-range over a > composite literal where the literal type is a user type (or alias). This is > true for both maps and array/slices, but the following example is with a > slice.

Re: [go-nuts] Strange behavior of range over composite literal.

2018-10-08 Thread Jan Mercl
On Mon, Oct 8, 2018 at 9:10 PM Raffaele Sena wrote: See https://golang.org/ref/spec#Composite_literals A parsing ambiguity arises when a composite literal using the TypeName form of the LiteralType appears as an operand between the keyword and the opening b

[go-nuts] Strange behavior of range over composite literal.

2018-10-08 Thread Raffaele Sena
I found a strange behavior (well, I would call it a bug) of for-range over a composite literal where the literal type is a user type (or alias). This is true for both maps and array/slices, but the following example is with a slice. My guess is that at the compiler level the for-range statement is