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

compile_lll.py: buggy translation of repeat when #iteration <= 0 #451

Closed
daejunpark opened this issue Nov 9, 2017 · 0 comments
Closed

Comments

@daejunpark
Copy link
Contributor

What's your issue about?

If the #iteration of repeat loop is less than or equal to 0, it replaces it by 2, which perhaps should not, while 1 would be more reasonable:
https://github.com/ethereum/viper/blob/b1fe12ddd8706ef3340a103916e3d3f2cc95ceef/viper/compile_lll.py#L96

Fortunately, for now, the repeat loops will be rejected in the preprocess phase if the #iteration is less than or equal to 0, but it would be good to fix for later:
https://github.com/ethereum/viper/blob/b1fe12ddd8706ef3340a103916e3d3f2cc95ceef/viper/parser/parser_utils.py#L113-L114

How can it be fixed?

Change the following line:
https://github.com/ethereum/viper/blob/b1fe12ddd8706ef3340a103916e3d3f2cc95ceef/viper/compile_lll.py#L96
to something like:

loops = num_to_bytearray(code.args[2].value) or [1]

or

loops = num_to_bytearray(code.args[2].value) or raise Exception(...)

Cute Animal Picture

                        _.-..
                      ,'9 )\)`-.,.--.
                      `-.|           `.
                         \,      ,    \)
                          `.  )._\   (\
                            |//   `-,//
                            ]||    //"
                     hjw    ""    ""
DavidKnott added a commit that referenced this issue Nov 16, 2017
Fix issue #451: buggy translation of `repeat` when #iteration <= 0
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

No branches or pull requests

1 participant