aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/devirtualize
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2023-06-05 09:30:58 -0700
committerGopher Robot <gobot@golang.org>2023-06-06 14:42:44 +0000
commitdb3f952b1f3c996085cb9bfe846590084f8fae2e (patch)
tree7ac934d1e760b91c5de10d89de60e51c7cdfae23 /src/cmd/compile/internal/devirtualize
parent512361fb1fa805f10f183e0b96248e523e68c192 (diff)
downloadgo-db3f952b1f3c996085cb9bfe846590084f8fae2e.tar.xz
cmd/compile/internal/syntax: better error message when using = instead of ==
When = is used instead of == as part of a conditional expression, the parser message emphasizes the LHS and RHS of = by always parenthesizing the two sides. For example, for: if x = y {} the error is: cannot use assignment (x) = (y) as value This is done to highlight the LHS and RHS in case of more complex cases such as if x || y = z {} which one may incorrectly read as (x) || (y == z) rather than the correct (x || y) = z. This CL fine-tunes the error message a bit by only adding the parentheses if the LHS and RHS are binary expressions. Fixes #60599. For #23385. Change-Id: Ida4c8d12464cc2ac15c934f24858eb6f43cf9950 Reviewed-on: https://go-review.googlesource.com/c/go/+/500975 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/devirtualize')
0 files changed, 0 insertions, 0 deletions