]> Cypherpunks repositories - gostls13.git/commit
[dev.regabi] cmd/compile: fix printing of method expressions
authorMatthew Dempsky <mdempsky@google.com>
Thu, 31 Dec 2020 02:43:10 +0000 (18:43 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 31 Dec 2020 05:52:09 +0000 (05:52 +0000)
commit477b049060966e90124edf950413575f84a9aa74
tree324146cc0d8bfe8ed539a4e961e4e471b882c743
parent178c667db2858f52965609b24857d5448dfb12c4
[dev.regabi] cmd/compile: fix printing of method expressions

OTYPE and OMETHEXPR were missing from OpPrec. So add them with the
same precedences as OT{ARRAY,MAP,STRUCT,etc} and
ODOT{,METH,INTER,etc}, respectively. However, ODEREF (which is also
used for pointer types *T) has a lower precedence than other types, so
pointer types need to be specially handled to assign them their
correct, lower precedence.

Incidentally, this also improves the error messages in issue15055.go,
where we were adding unnecessary parentheses around the types in
conversion expressions.

Thanks to Cuong Manh Le for writing the test cases for #43428.

Fixes #43428.

Change-Id: I57e7979babe3ed9ef8a8b5a2a3745e3737dd785f
Reviewed-on: https://go-review.googlesource.com/c/go/+/280873
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/ir/fmt.go
test/fixedbugs/issue15055.go
test/fixedbugs/issue43428.go [new file with mode: 0644]