Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slice (address).code disallowed with constant #4360

Open
Philogy opened this issue Nov 14, 2024 · 2 comments
Open

Slice (address).code disallowed with constant #4360

Philogy opened this issue Nov 14, 2024 · 2 comments
Assignees
Labels
bug - type 0 compiler halts or panics instead of generating code bug - UX a bug related to UX

Comments

@Philogy
Copy link

Philogy commented Nov 14, 2024

Version Information

  • vyper Version (output of vyper --version): 0.4.0+commit.e9db8d9
  • OS: osx
  • Python Version (output of python --version): 3.12.4

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,
@Philogy Philogy added the needs triage needs triage label Nov 14, 2024
@charles-cooper charles-cooper added bug - UX a bug related to UX bug - type 0 compiler halts or panics instead of generating code and removed needs triage needs triage labels Nov 19, 2024
@charles-cooper
Copy link
Member

repro:

SIZE: constant(uint256) = 5

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

@trocher
Copy link
Contributor

trocher commented Nov 19, 2024

Subset of #4190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - type 0 compiler halts or panics instead of generating code bug - UX a bug related to UX
Projects
None yet
Development

No branches or pull requests

5 participants