Re: [go-nuts] Struct literal in condition of if statement yields compile error

2018-02-06 Thread Patrick Smith
On Tue, Feb 6, 2018 at 1:37 PM, Jan Mercl <0xj...@gmail.com> wrote: > > Not a bug. 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 >

Re: [go-nuts] Struct literal in condition of if statement yields compile error

2018-02-06 Thread Jan Mercl
On Tue, Feb 6, 2018 at 10:31 PM Patrick Smith wrote: > Obviously I can code around this, but is it a bug that should be reported? Not a bug. See https://golang.org/ref/spec#Composite_literals A parsing ambiguity arises when a composite literal using the TypeName form of the LiteralType a

[go-nuts] Struct literal in condition of if statement yields compile error

2018-02-06 Thread Patrick Smith
See https://play.golang.org/p/cO4LQFk7ew- Given a struct definition type S struct { a, b int } an if statement of the form if x == S{ 0, 1 } { ... } yields compile errors such as prog.go:19:18: syntax error: unexpected }, expecting := or = or comma prog.go:22:1: syntax error: non-declaration