-
Notifications
You must be signed in to change notification settings - Fork 382
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
fix(gnovm): assignment operators require 1 expression on both sides #1943
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1943 +/- ##
=======================================
Coverage 47.78% 47.78%
=======================================
Files 393 393
Lines 61608 61602 -6
=======================================
Hits 29437 29437
+ Misses 29701 29695 -6
Partials 2470 2470 ☔ View full report in Codecov by Sentry. |
I double-checked, and this same check is supposed to be done for all assignment operators (like I've made the changes, just want to get another approval before merging this. |
…nolang#1943) > This PR fixes a bug in the GnoVM which executes incorrect statements like `s, ok <<= m["a"]`. The following code currently executes on gno: ```go package main func main() { m := map[string]int{"a": 1} var s int var ok bool s, ok <<= m["a"] println(s, ok) } ``` ![wat](https://github.com/gnolang/gno/assets/4681308/4545aadb-f255-49b0-863f-2506311f11e7) This PR matches the behaviour on assignment statements to the Go specification: > An assignment operation x op= y where op is a binary [arithmetic operator](https://go.dev/ref/spec#Arithmetic_operators) is equivalent to x = x op (y) but evaluates x only once. The op= construct is a single token. **In assignment operations, both the left- and right-hand expression lists must contain exactly one single-valued expression,** and the left-hand expression must not be the blank identifier.
The following code currently executes on gno:
This PR matches the behaviour on assignment statements to the Go specification: