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

fixes: #2142 #2143

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions tests/functional/codegen/test_struct_return.py
Original file line number Diff line number Diff line change
@@ -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]

2 changes: 1 addition & 1 deletion vyper/parser/external_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down