Skip to content

Commit

Permalink
fix: calls as arguments within calls
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Oct 9, 2020
1 parent 7f6b124 commit 1b79e44
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions vyper/parser/self_call.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import itertools

from vyper import ast as vy_ast
from vyper.codegen.abi import abi_decode
from vyper.exceptions import (
StateAccessViolation,
StructureException,
TypeCheckFailure,
)
from vyper.parser.lll_node import LLLnode
from vyper.parser.parser_utils import getpos, pack_arguments
from vyper.parser.parser_utils import getpos, make_setter, pack_arguments
from vyper.signatures.function_signature import FunctionSignature
from vyper.types import (
BaseType,
Expand Down Expand Up @@ -69,8 +70,23 @@ def make_call(stmt_expr, context):
expr_args = []
for arg in stmt_expr.args:
lll_node = Expr(arg, context).lll_node
context.new_placeholder(lll_node.typ)
expr_args.append(lll_node)
if isinstance(arg, vy_ast.Call):
# if the argument is a function call, perform the call seperately and
# assign it's result to memory, then reference the memory location when
# building this call. otherwise there is potential for memory corruption
target = LLLnode.from_list(
context.new_placeholder(lll_node.typ),
typ=lll_node.typ,
location="memory",
pos=getpos(arg),
)
setter = make_setter(target, lll_node, "memory", pos=getpos(arg))
expr_args.append(
LLLnode.from_list(target, typ=lll_node.typ, pos=getpos(arg), location="memory")
)
pre_init.append(setter)
else:
expr_args.append(lll_node)

sig = FunctionSignature.lookup_sig(context.sigs, method_name, expr_args, stmt_expr, context,)

Expand Down

0 comments on commit 1b79e44

Please sign in to comment.