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: global var dependencies #2077

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

fix: global var dependencies #2077

wants to merge 46 commits into from

Conversation

petar-dambovaliev
Copy link
Contributor

@petar-dambovaliev petar-dambovaliev commented May 13, 2024

fixes this by adding missing logic in in findUndefined2

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label May 13, 2024
@petar-dambovaliev petar-dambovaliev marked this pull request as ready for review May 13, 2024 12:16
Copy link

codecov bot commented May 13, 2024

Codecov Report

Attention: Patch coverage is 55.17241% with 65 lines in your changes missing coverage. Please review.

Project coverage is 60.83%. Comparing base (aa4bc99) to head (05f348a).

Files with missing lines Patch % Lines
gnovm/pkg/gnolang/preprocess.go 55.17% 57 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2077      +/-   ##
==========================================
- Coverage   60.83%   60.83%   -0.01%     
==========================================
  Files         563      563              
  Lines       75169    75314     +145     
==========================================
+ Hits        45730    45818      +88     
- Misses      26072    26125      +53     
- Partials     3367     3371       +4     
Flag Coverage Δ
contribs/gnodev 61.46% <ø> (+0.81%) ⬆️
contribs/gnofaucet 15.31% <ø> (+0.85%) ⬆️
gno.land 67.21% <ø> (ø)
gnovm 65.54% <55.17%> (-0.05%) ⬇️
misc/genstd 80.54% <ø> (ø)
misc/logos 19.88% <ø> (-0.36%) ⬇️
tm2 62.09% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Left some nitty comments 🙏

Overall looks good, thank you for the fix 🙏

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
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go 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.

Please also add more tests to check for different cases, thanks!

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Jun 12, 2024
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.

The tests are still not covering a bunch of the cases:

https://app.codecov.io/gh/gnolang/gno/pull/2077?src=pr&el=tree

DeferStmt, BlockStmt and other are not tested entirely. Please address the issues and add test cases which check against their conditions, as well as error conditions.

For a feature like this, there cannot be only 1 filetest.

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
gnovm/pkg/gnolang/preprocess.go Outdated Show resolved Hide resolved
gnovm/tests/files/var21.gno Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Show resolved Hide resolved
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.

This is the first part of my review. I want to make sure I understand the intentions before completing it.

Tell me if I have the main idea of what this is solving. Previously, names referenced by globally defined function literals were not being verified to have been defined. These changes use this unique case as an entrypoint to recursively analyze all of the function literal's statements to ensure that all names referenced are actually defined.

Otherwise, please see the couple of comments I've left.

existsLocal := func(name Name, bn BlockNode) bool {
curr := bn
for {
currNames := bn.GetBlockNames()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be bn.GetBlockNames() or curr.GetBlockNames()?

if name != "" {
pkg := packageOf(last)

if _, _, ok := pkg.FileSet.GetDeclForSafe(name); !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this return "" if this method returns true, indicating that the name is defined?

@petar-dambovaliev
Copy link
Contributor Author

This is the first part of my review. I want to make sure I understand the intentions before completing it.

Tell me if I have the main idea of what this is solving. Previously, names referenced by globally defined function literals were not being verified to have been defined. These changes use this unique case as an entrypoint to recursively analyze all of the function literal's statements to ensure that all names referenced are actually defined.

Otherwise, please see the couple of comments I've left.

Yes, that is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 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.

in variable initialization, dependencies within functions are not recursively resolved
7 participants