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

Exit statements with succeeding code not prevented in For loops. #3223

Closed
trocher opened this issue Jan 11, 2023 · 0 comments · Fixed by #3731
Closed

Exit statements with succeeding code not prevented in For loops. #3223

trocher opened this issue Jan 11, 2023 · 0 comments · Fixed by #3731

Comments

@trocher
Copy link
Contributor

trocher commented Jan 11, 2023

Version Information

  • vyper Version (output of vyper --version): 0.3.8+commit.ae7d6d28
  • OS: OSX
  • Python Version (output of python --version): 3.8.0

What's your issue about?

The compiler checks that there is no exit statements (Return, Selfdestruct, Raise) with succeeding code (that would not execute) including other exit statements.

As For loops are not checked for this matter by the compiler it is possible to compile exit statements with succeeding code.

For example, in the following, foo will fail to compile due to a StructureException (Exit statement with succeeding code) while bar would compile.

@external
def foo():
    if(True):
        return
        a:uint256 = 2
@external
def bar():
    for i in range(12):
        return
        a:uint256 = 2

How can it be fixed?

Adding a case to handle For statements in check_single_exit should be enough to fix the issue.

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 a pull request may close this issue.

1 participant