-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: spurious error when ~ is used as an infix operator #23587
Comments
Thank you @davecheney for this report and it is great to see you here in the new year! @griesemer I see that in the scanning phase we recognize that people commonly use the bitwise complement '~' in other languages, and perhaps intentionally fallthrough to continue lexical analysis as we are doing in the context of the proper operator in Go However, in this context I believe that the entire operation is invalid irrespective of the types of operands i.e, even if it were |
The scanner doesn't know about context (are there one or two operands) and thus cannot make that distinction. One could pass through the go/types says: |
Hey all, thanks for looking into this issue. I'm less interested in the first line, and more interested in the second
As the code sample never mentions ^ |
@davecheney Yes, thanks for pointing that out. During lexical analysis, the scanner assumes that if a user typed |
Change https://golang.org/cl/94160 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.9.3
Does this issue reproduce with the latest release?
Unknown
What operating system and processor architecture are you using (
go env
)?Go playground
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
prog.go:5:8: bitwise complement operator is ^
What did you see instead?
prog.go:5:8: bitwise complement operator is ^
prog.go:5:8: invalid operation: a ^ a (operator ^ not defined on bool)
The text was updated successfully, but these errors were encountered: