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

Overflow in loop #1712

Closed
FranciscoDomingues opened this issue Nov 9, 2019 · 3 comments
Closed

Overflow in loop #1712

FranciscoDomingues opened this issue Nov 9, 2019 · 3 comments
Assignees
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@FranciscoDomingues
Copy link

Version Information

Tested on Remix

What's your issue about?

It appears there is no overflow checking for the loop variables. For example, the code

@public
def test_for() -> int128:
  a: int128 = 0
  for i in range(MAX_INT128, MAX_INT128+2):
        a = i
  return a

returns -2**127.

@fubuloubu
Copy link
Member

Good catch!

@fubuloubu fubuloubu added the bug Bug that shouldn't change language semantics when fixed. label Nov 10, 2019
@jacqueswww
Copy link
Contributor

Looking at this.

@fubuloubu fubuloubu added this to To do in v1.0 Release Candidate via automation Jan 6, 2020
@fubuloubu fubuloubu added this to the v0.2 Release milestone Jun 22, 2020
@fubuloubu fubuloubu self-assigned this Jun 28, 2020
@fubuloubu
Copy link
Member

fubuloubu commented Jun 28, 2020

Fixed in #2029

Error:

E           vyper.exceptions.TypeMismatch: Given reference has type uint256, expected int128
E           function 'test_for', line 6:12 
E                5     for i in range(MAX_INT128, MAX_INT128+2):
E           ---> 6         a = i
E           -------------------^
E                7     return a

Added this test case in #2067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
Development

No branches or pull requests

3 participants