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: branch stmts #3043

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

fix: branch stmts #3043

wants to merge 12 commits into from

Conversation

petar-dambovaliev
Copy link
Contributor

@petar-dambovaliev petar-dambovaliev commented Oct 29, 2024

Adds validation for break, continue and fallthrough to disallow invalid code.
Moves existing validation from the runtime to the preprocessor.

Closes #2973

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Oct 29, 2024
@petar-dambovaliev petar-dambovaliev changed the title Bug: fix switch branch stmts fix: switch branch stmts Oct 29, 2024
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 1, 2024
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.73%. Comparing base (4f27a57) to head (919f650).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3043      +/-   ##
==========================================
- Coverage   63.77%   63.73%   -0.05%     
==========================================
  Files         548      548              
  Lines       78681    78695      +14     
==========================================
- Hits        50180    50157      -23     
- Misses      25117    25148      +31     
- Partials     3384     3390       +6     
Flag Coverage Δ
contribs/gnodev 61.16% <ø> (+0.62%) ⬆️
contribs/gnofaucet 15.77% <ø> (+0.94%) ⬆️
gno.land 73.62% <ø> (ø)
gnovm 67.93% <100.00%> (+<0.01%) ⬆️
misc/genstd 79.72% <ø> (ø)
tm2 62.31% <ø> (-0.16%) ⬇️

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.

gnovm/pkg/gnolang/preprocess.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/preprocess.go Outdated Show resolved Hide resolved

if n.GetAttribute(ATTR_LAST_BLOCK_STMT) != true {
// no more clause after the one executed, this is not allowed
panic("fallthrough statement out of place")
Copy link
Contributor

Choose a reason for hiding this comment

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

any test targeting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several tests. grep for fallthrough statement out of place

ATTR_LOOP_DEFINES GnoAttribute = "ATTR_LOOP_DEFINES" // []Name defined within loops.
ATTR_LOOP_USES GnoAttribute = "ATTR_LOOP_USES" // []Name loop defines actually used.
ATTR_SHIFT_RHS GnoAttribute = "ATTR_SHIFT_RHS"
ATTR_LAST_BLOCK_STMT GnoAttribute = "ATTR_LAST_BLOCK_STMT"
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a better name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am open to suggestions

@Kouteki Kouteki added this to the 🚀 Mainnet launch milestone Nov 10, 2024
@petar-dambovaliev petar-dambovaliev changed the title fix: switch branch stmts fix: branch stmts Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in focus Core team is prioritizing this work 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

can break out of a self-executing closure
4 participants