Vyper: Constants can't be used for the list size

Created on 31 Dec 2018  路  3Comments  路  Source: vyperlang/vyper

Version Information

  • vyper Version: 1.0.0b6
  • OS: osx
  • Python Version : 3.6

What's your issue about?

I got Unknown list type. error when I used constants for the list size.

e.g.

TREE_DEPTH: constant(uint256) = 16

@public
def calcMerkleRoot(_proof: bytes32[TREE_DEPTH]):
    pass

With bytes[TREE_DEPTH] (fixed-size byte arrays) the same error occurs.

I'm not sure this is an error or intended but constants for the list size would be useful.

How can it be fixed?

Cute Animal Picture

image

bug

Most helpful comment

I think the current listType parser in line 329~349 of types.py does not support elif isinstance(item.slice.value, ast.Name):, whereas ast.Num is supported. so the variable jumps into else statement case and shows error 'Unknown list type'. I will see what I can do. I will probably add logic to look up value in ast.Name, check its type, and apply same logic as ast.Num does if its value is an integer.

All 3 comments

I think the current listType parser in line 329~349 of types.py does not support elif isinstance(item.slice.value, ast.Name):, whereas ast.Num is supported. so the variable jumps into else statement case and shows error 'Unknown list type'. I will see what I can do. I will probably add logic to look up value in ast.Name, check its type, and apply same logic as ast.Num does if its value is an integer.

@nrryuya please test constant fixes have just been merged ;)

@jacqueswww
This is fixed! Thank you ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yudetamago picture yudetamago  路  4Comments

haydenadams picture haydenadams  路  3Comments

ben-kaufman picture ben-kaufman  路  4Comments

jacqueswww picture jacqueswww  路  3Comments

ben-kaufman picture ben-kaufman  路  4Comments