On Wed, Aug 24, 2016 at 9:21 PM, sbkim via golang-nuts
<golang-nuts@googlegroups.com> wrote:
> Hello group,
>
> Why are the following snippets errors?
>
> https://play.golang.org/p/mgEYMNNw9h
> type S struct {
>  i int
> }
>
>  if S{i: 0} == S{} {
>  }
> syntax error: unexpected == at end of statement
>
>  switch S{i: 0} == S{} {
>  }
> syntax error: unexpected i, expecting case or default or }
>
> It works without error if you surround each literal with ( ), or the entire
> comparison expression with ( ).
> The following also works without error:
>  _ = S{i: 0} == S{}
>
> Does the language spec state those are errors, or is this a bug in the
> parser?

Search for "parsing ambiguity" in
https://golang.org/ref/spec#Composite_literals .

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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to