Skip to content
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): correct type for shift expression #1775

Open
wants to merge 146 commits into
base: master
Choose a base branch
from

Conversation

ltzmaxwell
Copy link
Contributor

@ltzmaxwell ltzmaxwell commented Mar 14, 2024

UPDATE: this one is ready for review.

shift operator where first operand is an untyped bigint always results in a bigint is not resolved by #1426, it's fixed by this one.

=================================================================

  1. This is a fix to shift operator where first operand is an untyped bigint always results in a bigint #1462;
  2. NOTE: This PR should be reviewed following the potential merger of feat: gno type check #1426, from which it is both decoupled and dependent. feat: gno type check #1426 serves as base branch of this one.
  3. NOTE: Currently, this PR displays all code including that from feat: gno type check #1426, because it is being compared to the master branch instead of differing against feat: gno type check #1426 directly.

@ltzmaxwell ltzmaxwell changed the title fix: correct type for shift expression fix(gnome): correct type for shift expression Aug 5, 2024
@ltzmaxwell ltzmaxwell changed the title fix(gnome): correct type for shift expression fix(gnovm): correct type for shift expression Aug 5, 2024
@ltzmaxwell
Copy link
Contributor Author

Hi @thehowl , this one is good to review too.

Copy link
Contributor

@deelawn deelawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I think there are a few things that need fixing. I appreciate all of the tests. The Go spec has a some nice cases that maybe we could also include as part of the tests: https://arc.net/l/quote/offplfsv

gnovm/pkg/gnolang/preprocess.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
@ltzmaxwell ltzmaxwell marked this pull request as draft August 8, 2024 10:06
@ltzmaxwell ltzmaxwell marked this pull request as ready for review August 9, 2024 09:53
Copy link
Contributor

@deelawn deelawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for quickly addressing my comments 🙏

gnovm/tests/files/types/shift_a11.gno Outdated Show resolved Hide resolved
gnovm/tests/files/types/shift_a7.gno Outdated Show resolved Hide resolved
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partial

gnovm/pkg/gnolang/values.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/values.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/values_conversions.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mvertes mvertes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR greatly improves the behaviour of the shift operator. The tests are amazing and cover a lot of corner cases (several bugs also found in yaegi thanks to them) and match perfectly the results given by the compiler. Thank you for this effort. My remarks are minor and do no block approval. We should merge it ASAP now.

@@ -0,0 +1,23 @@
package main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is maybe legitimate but it has nothing to do with the shift operator. It should be renamed or suppressed.

Comment on lines +10 to +13

//s1 := []int{0}
//s1[0] = 1 + 1<<2
//fmt.Printf("%T\n", s1[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//s1 := []int{0}
//s1[0] = 1 + 1<<2
//fmt.Printf("%T\n", s1[0])

@@ -0,0 +1,10 @@
package main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test has nothing to do with shift. Please rename it or suppress it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

7 participants