From 7c1d5926f8356c823ce08bb260edca0d0a32ffb9 Mon Sep 17 00:00:00 2001 From: saikat041 Date: Fri, 4 Sep 2020 16:23:10 +0530 Subject: [PATCH] Fix issue: #2142 --- .../functional/codegen/test_struct_return.py | 31 +++++++++++++++++++ vyper/parser/external_call.py | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/functional/codegen/test_struct_return.py diff --git a/tests/functional/codegen/test_struct_return.py b/tests/functional/codegen/test_struct_return.py new file mode 100644 index 0000000000..04e2d61e3e --- /dev/null +++ b/tests/functional/codegen/test_struct_return.py @@ -0,0 +1,31 @@ +import pytest + +@pytest.mark.parametrize("string", ["a", "abc", "abcde", "potato"]) +def test_string_inside_tuple(get_contract, string): + code = f""" +struct Person: + name: String[6] + age: uint256 + +@external +def test_return() -> Person: + return Person({{ name:"{string}", age:42 }}) + """ + c1 = get_contract(code) + + code = """ +struct Person: + name: String[6] + age: uint256 + +interface jsonabi: + def test_return() -> Person: view + +@external +def test_values(a: address) -> Person: + return jsonabi(a).test_return() + """ + + c2 = get_contract(code) + assert c2.test_values(c1.address) == [string, 42] + diff --git a/vyper/parser/external_call.py b/vyper/parser/external_call.py index 0df7091fca..48ab6ac338 100644 --- a/vyper/parser/external_call.py +++ b/vyper/parser/external_call.py @@ -89,7 +89,7 @@ def external_call(node, context, interface_name, contract_address, pos, value=No if isinstance(output_type, ByteArrayLike): types_list = (output_type,) elif isinstance(output_type, TupleLike): - types_list = output_type.members + types_list = output_type.tuple_members() else: raise