vyperlang / vyper

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

Slice (address).code disallowed with constant #4360

Open Philogy opened 2 weeks ago

Philogy commented 2 weeks ago

Version Information

What's your issue about?

I cannot do slice(address.code, offset, SOME_CONSTANT) if SOME_CONSTANT is defined as SOME_CONSTANT: constant(uint256) giving me the error:

Error: Compiler run failed:
Location: src/periphery/ControllerV1.vy
(address).code is only allowed inside of a slice function with a constant length

  contract "src/periphery/ControllerV1.vy:155", function "_get_partial_key", line 155:8 
       154     section: Bytes[CONFIG_ENTRY_SIZE] = slice(
  ---> 155         store.code,
  -----------------^
       156         STORE_HEADER_SIZE + index * CONFIG_ENTRY_SIZE,
charles-cooper commented 1 week ago

repro:

SIZE: constant(uint256) = 5

@external
def foo(index: uint256) -> Bytes[256]:
    return slice((msg.sender).code, index, SIZE)
trocher commented 1 week ago

Subset of #4190