]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: better error when trying to use ~ as bitwise operation
authorRobert Griesemer <gri@golang.org>
Tue, 31 Jan 2023 19:34:16 +0000 (11:34 -0800)
committerGopher Robot <gobot@golang.org>
Wed, 1 Feb 2023 21:30:59 +0000 (21:30 +0000)
commit07dca0fe14d717f7e44593d13d9a6767ec34a9cc
treebd78151989633a354ecf1165023ba7584e317263
parentcda461bb79624f9ee14fd0619bef456d27d23d88
go/types, types2: better error when trying to use ~ as bitwise operation

When coming from C, the bitwise integer complement (bitwise negation)
operator is ~, but in Go it is ^. Report an error mentioning ^ when
~ is used with an integer operand.

Background: Some articles on the web claim that Go doesn't have a
bitwise complement operator.

Change-Id: I41185cae4a70d528754e44f42c13c013ed91bf27
Reviewed-on: https://go-review.googlesource.com/c/go/+/463747
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/types2/expr.go
src/go/types/expr.go
src/internal/types/testdata/check/expr0.go