Vyper: Constants support for range

Created on 26 Nov 2018  路  5Comments  路  Source: vyperlang/vyper

Range should support constants int as an input.

What's your issue about?

TREE_FIDDY: constant(uint256)  = 350                                                                                                                                       


def a():                                                                                                                                                                 
    for i in range(TREE_FIDDY):                                                                                                                                                 
         if i == 3:                                                                                                                                                      
              break

How can it be fixed?

See parse_for in stmt.py.

vyper.exceptions.StructureException: line 5: Range only accepts literal values
    for i in range(ONE):                                                                                                                                                 
-------------^

Cute Animal Picture

bug

All 5 comments

Updated the constant in your example because ONE = 50 made no sense to me lol

LOL!

Starting work on this.

Hi

It's fixed ?

TREE_FIDDY: int128                                                                                                                                  


@public
def a():          
    self.TREE_FIDDY=12
    for i in range(self.TREE_FIDDY):                                                                                                                                                 
        if i == 3:                                                                                                                                                      
            break
line 7: Range only accepts literal values
    for i in range(self.TREE_FIDDY):                                                                                                                                                 
-------------^

Yes, constans don't use self.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nrryuya picture nrryuya  路  4Comments

pipermerriam picture pipermerriam  路  3Comments

vici0 picture vici0  路  3Comments

robinsierra picture robinsierra  路  3Comments

fubuloubu picture fubuloubu  路  3Comments