Skip to content

fixes: #2142#2143

Merged
fubuloubu merged 1 commit into
vyperlang:masterfrom
saikat041:fix-#2142
Sep 4, 2020
Merged

fixes: #2142#2143
fubuloubu merged 1 commit into
vyperlang:masterfrom
saikat041:fix-#2142

Conversation

@saikat041

@saikat041 saikat041 commented Sep 4, 2020

Copy link
Copy Markdown
Contributor

What I did

fixes: #2142

How I did it

types_list = output_type.members

Changed types_list = output_type.members to types_list = output_type.tuple_members(). In the case of struct, output_type.members returns a dict object, but types_list should be a list of types

How to verify it

Runt the following test case

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]

@codecov-commenter

codecov-commenter commented Sep 4, 2020

Copy link
Copy Markdown

Codecov Report

Merging #2143 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2143   +/-   ##
=======================================
  Coverage   84.95%   84.95%           
=======================================
  Files          83       83           
  Lines        8333     8333           
  Branches     2012     2012           
=======================================
  Hits         7079     7079           
  Misses        752      752           
  Partials      502      502           
Impacted Files Coverage Δ
vyper/parser/external_call.py 83.33% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce88755...7c1d592. Read the comment docs.

@fubuloubu

Copy link
Copy Markdown
Contributor

Nice!

@fubuloubu fubuloubu merged commit 2500f9e into vyperlang:master Sep 4, 2020
@saikat041 saikat041 changed the title Fix issue: #2142 fixes: #2142 Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Returning struct from a external function gives error

3 participants