-
Notifications
You must be signed in to change notification settings - Fork 387
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
vm: variable declaration code in AssignStmt
and ValueDecl
should be synced (issues with map index / type assertion tuple assignment)
#1958
Labels
Milestone
Comments
zivkovicmilos
added
🌟 improvement
performance improvements, refactors ...
📦 🤖 gnovm
Issues or PRs gnovm related
labels
Apr 26, 2024
Just a first comment: seems that "tuple" map indexes and type assertions are now supported in the var syntax, I don't have any error when executing the code mentioned above. I'm working on refactoring code. |
6 tasks
ltzmaxwell
pushed a commit
that referenced
this issue
Nov 21, 2024
This PR aims at fixing this issue [1958](#1958) <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details> --------- Co-authored-by: hieu.ha <[email protected]> Co-authored-by: Mikael VALLENET <[email protected]>
Fixed by #3017 |
github-project-automation
bot
moved this from In Progress
to Done
in 🧙♂️gno.land core team
Nov 25, 2024
r3v4s
pushed a commit
to gnoswap-labs/gno
that referenced
this issue
Dec 10, 2024
This PR aims at fixing this issue [1958](gnolang#1958) <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [ ] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests </details> --------- Co-authored-by: hieu.ha <[email protected]> Co-authored-by: Mikael VALLENET <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
The Go spec states:
There is one notable exception, which is that the shorthand
:=
allows for "redeclarations" on the LHS, so long as at least one name isn't being redeclared. The other difference is that thevar
syntax can be used to declare global variables, while:=
can't.Currently, the GnoVM has two very different handling of these two statements, which according to the go spec should work the same (at least for their use in function bodies):
gno/gnovm/pkg/gnolang/preprocess.go
Line 1538 in 5a976ef
gno/gnovm/pkg/gnolang/preprocess.go
Line 1804 in 5a976ef
The changes don't concern only this
TRANS_LEAVE
block, though it is one where the difference is most significant.The practical consequence is that there are key differences in behaviour when using the
var
syntax or the:=
syntax; for instance, "tuple" map indexes and type assertions are not supported in thevar
syntax:https://play.gno.land/p/wvIG65jLGmT
https://play.gno.land/p/FMC5fHKjlgg
You can easily note in the playground how, switching the statements to the corresponding
:=
statements, the statement will work again.To avoid further bugs, we should try to unify as much as possible the code for preprocessing both expressions, so that there is no surprising behaviour at runtime for two variables declared with the different syntaxes
The text was updated successfully, but these errors were encountered: