Skip to content

Commit

Permalink
move raw_call check to fetch_call_return
Browse files Browse the repository at this point in the history
  • Loading branch information
tserg committed Mar 8, 2024
1 parent 19baa5d commit a33c7a8
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions vyper/builtins/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,25 @@ def fetch_call_return(self, node):

kwargz = {i.arg: i.value for i in node.keywords}

delegate_call = kwargz.get("is_delegate_call")
static_call = kwargz.get("is_static_call")
if delegate_call and static_call:
raise ArgumentException(
"Call may use one of `is_delegate_call` or `is_static_call`, not both"
)

value = kwargz.get("value")
if (delegate_call or static_call) and value is not None:
raise ArgumentException("value= may not be passed for static or delegate calls!")

fn_node = node.get_ancestor(vy_ast.FunctionDef)
fn_type = fn_node._metadata["func_type"]
if not static_call and not fn_type.is_mutable:
raise StateAccessViolation(
f"Cannot make modifying calls from {fn_type.mutability},"
" use `is_static_call=True` to perform this action"
)

outsize = kwargz.get("max_outsize")
if outsize is not None:
outsize = outsize.get_folded_value()
Expand Down Expand Up @@ -1106,20 +1125,6 @@ def build_IR(self, expr, args, kwargs, context):
kwargs["revert_on_failure"],
)

if delegate_call and static_call:
raise ArgumentException(
"Call may use one of `is_delegate_call` or `is_static_call`, not both"
)

if (delegate_call or static_call) and value.value != 0:
raise ArgumentException("value= may not be passed for static or delegate calls!")

if not static_call and context.is_constant():
raise StateAccessViolation(
f"Cannot make modifying calls from {context.pp_constancy()},"
" use `is_static_call=True` to perform this action"
)

if data.value == "~calldata":
call_ir = ["with", "mem_ofst", "msize"]
args_ofst = ["seq", ["calldatacopy", "mem_ofst", 0, "calldatasize"], "mem_ofst"]
Expand Down

0 comments on commit a33c7a8

Please sign in to comment.