What version of Go are you using (go version)?
$ go version
go version go1.14.1 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
https://play.golang.org/p/TACak6vfX1a
package main
import (
"fmt"
)
type foo struct{}
func main() {
u := foo{}
if (u != foo{}) { // With () it works
fmt.Println("OK")
}
if u != foo{} { // This doesn't compile
fmt.Println("hello")
}
}
What did you expect to see?
No compile error
What did you see instead?
if u != foo{} { does not compile:
./main.go:16:16: syntax error: unexpected { at end of statement
./main.go:19:1: syntax error: non-declaration statement outside function body
Adding parentheses works:
if (u != foo{}) {
if u != (foo{}) {
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What did you do?
https://play.golang.org/p/TACak6vfX1a
What did you expect to see?
No compile error
What did you see instead?
if u != foo{} {does not compile:Adding parentheses works:
if (u != foo{}) {if u != (foo{}) {