What version of Go are you using (go version)?
$ go version go1.16.4 linux/amd64
and
$ go version go1.17.4 linux/amd64
What did you do?
https://go.dev/play/p/eIJEXrkKD8m
package main
import "log"
func main() {
if T{}.Name() == "T" {
log.Println("T")
}
}
type T struct {}
func (t T) Name() string { return "T" }
I'd like to mention, that compiling with new(T) or extra parenthesis around T{}.Name() was successful. Seems to me that if T{ was parsed as beginning of the if scope.
At a first glance seems like two situations can be distinguished by having/not having a method call after parenthesis is closed
What did you expect to see?
Code compiled successfully
What did you see instead?
./prog.go:6:8: syntax error: unexpected . at end of statement
./prog.go:9:1: syntax error: non-declaration statement outside function body
What version of Go are you using (
go version)?What did you do?
https://go.dev/play/p/eIJEXrkKD8m
I'd like to mention, that compiling with
new(T)or extra parenthesis aroundT{}.Name()was successful. Seems to me thatif T{was parsed as beginning of theifscope.At a first glance seems like two situations can be distinguished by having/not having a method call after parenthesis is closed
What did you expect to see?
Code compiled successfully
What did you see instead?