vyper --version): 0.2.4+commit.7949850python --version): Python 3.7.3pip freeze):Unclear ambiguous type error on a simple code.
# @version 0.2.4
from vyper.interfaces import ERC20
coins: constant(address[4]) = [
0x6B175474E89094C44Da98b954EedeAC495271d0F,
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,
0xdAC17F958D2ee523a2206206994597C13D831ec7,
0x0000000000085d4780B73119b644AE5ecd22b376,
]
@external
def recycle():
balances: uint256[4] = empty(uint256[4])
for i in range(4):
balances[i] = ERC20(coins[i]).balanceOf(msg.sender)
StructureException: Ambiguous type
contract "contracts/Recycle.vy", function "recycle", line 31:28
30 for i in range(4):
---> 31 balances[i] = ERC20(coins[i]).balanceOf(msg.sender)
------------------------------------^
You tell me
Looks like constant folding is the issue... coins[i] ends up changed to [0x6B175474E89094C44Da98b954EedeAC495271d0F, 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x0000000000085d4780B73119b644AE5ecd22b376][i] and the type checker gets confused if it's looking at an address[4] or a Bytes[20][4].
I see two issues to address here:
Most helpful comment
Looks like constant folding is the issue...
coins[i]ends up changed to[0x6B175474E89094C44Da98b954EedeAC495271d0F, 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x0000000000085d4780B73119b644AE5ecd22b376][i]and the type checker gets confused if it's looking at anaddress[4]or aBytes[20][4].I see two issues to address here: