vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.84k stars 788 forks source link

bug: multiple evaluations of DST lead to non-unique symbol error when copying byte arrays or dynamic arrays #3514

Open tserg opened 1 year ago

tserg commented 1 year ago

Version Information

What's your issue about?

The destination of byte arrays and dynamic arrays copying is evaluated multiple times as cache_when_complex is not used. This includes make_byte_array_copier and _dynarray_make_setter (both cases: src.value == "multi" and src.value != "multi").

This contract fails to compile with the following error: AssertionError: non-unique symbols {'self.bar()2'}.

a: DynArray[DynArray[uint256, 2],2]

@external
def foo():
    self.a[self.bar()] = [1, 2]

@internal
def bar() -> uint256:
    return 0

reported by @trocher

How can it be fixed?

Fill this in if you know how to fix it.

trocher commented 11 months ago

Another example to add to tests when the issue will be patched:

d:String[4]

@internal
def bar()->uint256:
    return 0
@external
def bar():
    f:DynArray[String[5], 1] = ["aaaaa"]
    f[self.bar()] = self.d