Skip to content

Commit

Permalink
fix folded length in slice; add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Nov 20, 2024
1 parent 3192574 commit c878485
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/functional/syntax/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ def foo():
def foo(a: address):
x: Bytes[32] = slice(a.code, 0, 31 + 1)
""",
"""
@external
def foo(inp: Bytes[5], start: uint256) -> Bytes[3]:
return slice(inp, 0, 1 + 1)
""",
]


Expand Down
2 changes: 1 addition & 1 deletion vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def fetch_call_return(self, node):

arg = node.args[0]
start_expr = node.args[1]
length_expr = node.args[2]
length_expr = node.args[2].reduced()

# CMC 2022-03-22 NOTE slight code duplication with semantics/analysis/local
is_adhoc_slice = arg.get("attr") == "code" or (
Expand Down

0 comments on commit c878485

Please sign in to comment.