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

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

fix: switch branch stmts #3043

wants to merge 6 commits into from

Conversation

petar-dambovaliev
Copy link
Contributor

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

Associated issue

@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.37%. Comparing base (d03581e) to head (26862b6).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3043      +/-   ##
==========================================
- Coverage   63.37%   63.37%   -0.01%     
==========================================
  Files         566      566              
  Lines       79490    79506      +16     
==========================================
+ Hits        50374    50384      +10     
- Misses      25727    25732       +5     
- Partials     3389     3390       +1     
Flag Coverage Δ
contribs/gnodev 60.57% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
gno.land 67.37% <ø> (ø)
gnovm 67.88% <100.00%> (+0.01%) ⬆️
misc/genstd 79.72% <ø> (ø)
tm2 62.33% <ø> (-0.05%) ⬇️

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.

@@ -2125,8 +2130,19 @@ func preprocess1(store Store, ctx BlockNode, n Node) Node {

// TRANS_LEAVE -----------------------
case *BranchStmt:

Copy link
Contributor

@ltzmaxwell ltzmaxwell Nov 4, 2024

Choose a reason for hiding this comment

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

delete this line for consistency.

@@ -2139,6 +2155,8 @@ func preprocess1(store Store, ctx BlockNode, n Node) Node {
}
}
case CONTINUE:
notAllowedFunc("continue")
Copy link
Contributor

@ltzmaxwell ltzmaxwell Nov 4, 2024

Choose a reason for hiding this comment

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

should this logic be merged into findContinuableNode and findBranchLabel, seems what we need to do is to make these two funcs correct.


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?

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?

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.

3 participants