vyper --version): 0.1.0b14+commit.c9f6162python --version): 3.6.2pip freeze):I have a contract like below:
Please include information like:
MAX_SUBS: constant(uint256) = 32
FEE_POOL: constant(wei_value) = 100000000000000000 # 0.1 ETH
STAKE_VALUE: constant(wei_value) = 3200000000000000000 # 3.2 ETH
lockUpBalance: wei_value
feeBalance: wei_value
owner: public(address)
@public
def __init__():
self.owner = msg.sender
@public
@constant
def getFeePool() -> wei_value:
return self.feeBalance
@public
@constant
def getLockUpPool() -> wei_value:
return self.lockUpBalance
Traceback (most recent call last):
File "/Users/trnhgquan/vyper-venv/bin/vyper", line 8, in <module>
sys.exit(_parse_cli_args())
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/cli/vyper_compile.py", line 57, in _parse_cli_args
return _parse_args(sys.argv[1:])
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/cli/vyper_compile.py", line 127, in _parse_args
args.show_gas_estimates
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/cli/vyper_compile.py", line 241, in compile_files
interface_codes=get_interface_codes(root_path, contract_sources)
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/compiler.py", line 333, in compile_codes
exc_handler(contract_name, exc)
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/cli/vyper_compile.py", line 159, in exc_handler
raise exception
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/compiler.py", line 329, in compile_codes
source_id=source_id
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/compiler.py", line 225, in _mk_bytecode_output
return '0x' + __compile(code, interface_codes=interface_codes).hex()
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/compiler.py", line 50, in __compile
runtime_only=kwargs.get('bytecode_runtime', False)
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/parser.py", line 203, in parse_tree_to_lll
o, otherfuncs, sigs, external_contracts, origcode, global_ctx, defaultfunc, runtime_only
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/parser.py", line 127, in parse_other_functions
parse_function(_def, {**{'self': sigs}, **external_contracts}, origcode, global_ctx)
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/function_definitions/parse_function.py", line 79, in parse_function
context=context,
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/function_definitions/parse_public_function.py", line 280, in parse_public_function
] + nonreentrant_post + [['stop']]
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/function_definitions/parse_public_function.py", line 278, in <listcomp>
for c
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/stmt.py", line 1013, in parse_body
return parse_stmt(code, context)
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/stmt.py", line 1007, in parse_stmt
return Stmt(stmt, context).lll_node
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/stmt.py", line 91, in __init__
self.lll_node = self.stmt_table[stmt_type]()
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/parser/stmt.py", line 809, in parse_return
if not SizeLimits.in_bounds(self.context.return_type.typ, sub.value):
File "/Users/trnhgquan/vyper-venv/lib/python3.6/site-packages/vyper/utils.py", line 117, in in_bounds
return 0 <= value <= cls.MAX_UINT256
TypeError: '<=' not supported between instances of 'int' and 'str'
getFeePool, getLockUpPool, the issues will dissapear and compiler work. Its so weird.The issue seems to be related to the use of wei_value as a tyoe on the storage variables. I'm able to compile the contract by making the following change to lines 5-6:
lockUpBalance: uint256(wei)
feeBalance: uint256(wei)
Thanks for letting us know, I will investigate further.
Quite strange indeed; must be an oversight in testing units as well. Closest I found was:
https://github.com/vyperlang/vyper/blob/65d17e6b1ec38b5803493b54fd76212b742ea9c4/tests/parser/globals/test_getters.py#L31
@iamdefinitelyahuman this works for me, maybe that helps your digging?
MAX_SUBS: constant(uint256) = 32
FEE_POOL: constant(uint256(wei)) = 100000000000000000 # 0.1 ETH
STAKE_VALUE: constant(uint256(wei)) = 3200000000000000000 # 3.2 ETH
lockUpBalance: uint256(wei)
feeBalance: uint256(wei)
owner: public(address)
@public
def __init__():
self.owner = msg.sender
@public
@constant
def getFeePool() -> uint256(wei):
a: uint256(wei) = self.feeBalance
return a
@public
@constant
def getLockUpPool() -> uint256(wei):
return self.lockUpBalance
Thank you @iamdefinitelyahuman and @jacqueswww . If wei_value & uint256(wei) is the same, I think should remove wei_value in the future.
Agreed removing wei_value is something I support.
Most helpful comment
The issue seems to be related to the use of
wei_valueas a tyoe on the storage variables. I'm able to compile the contract by making the following change to lines 5-6:Thanks for letting us know, I will investigate further.