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

fixed the compiler panicking when a break is outside of a loop #3177

Merged
merged 2 commits into from
Dec 7, 2022

Conversation

trocher
Copy link
Contributor

@trocher trocher commented Dec 7, 2022

What I did

Fixed #3176

How I did it

Removed vy.ast.Break from ignored_types in FunctionNodeVisitor and created a function Visit_Break that behave similarly to visit_Continue to check that the break statement is enclosed in a loop.

How to verify it

Compiling the following contract will now output vyper.exceptions.StructureException: `break` must be enclosed in a `for` loop instead of the compiler panicking.

@external
def foo():
    break

Commit message

fix: improve error message for break statement outside of a loop

Description for the changelog

Improve error message for break statement outside of a loop

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Dec 7, 2022

Codecov Report

Merging #3177 (20410c0) into master (ac2fa14) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3177   +/-   ##
=======================================
  Coverage   88.48%   88.48%           
=======================================
  Files          85       85           
  Lines       10756    10760    +4     
  Branches     2286     2287    +1     
=======================================
+ Hits         9517     9521    +4     
  Misses        789      789           
  Partials      450      450           
Impacted Files Coverage Δ
vyper/semantics/analysis/local.py 91.21% <100.00%> (+0.10%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

Good work! Can we add a test showing the compiler successfully throws under this scenario?

@fubuloubu fubuloubu enabled auto-merge (squash) December 7, 2022 13:18
@fubuloubu fubuloubu merged commit 1a568bf into vyperlang:master Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Break outside of loop leads to Compiler Panic
3 participants