Skip to content

Nonsense struct output with inline returns #1551

Closed
@NoahZinsmeister

Description

@NoahZinsmeister

Version Information

  • vyper Version (output of vyper --version): 0.1.0b10
  • OS: osx
  • Python Version (output of python --version): Python 3.7.2
  • Environment (output of pip freeze):
eth-tester==0.1.0b39
py-evm==0.2.0a42
pytest==5.0.1
vyper==0.1.0b10
web3==5.0.0b2

What's your issue about?

When @public functions which return structs are returned inline from other @public functions, the output is nonsense values.

In the following code, wrap_get_my_struct_WORKING returns the correct data, whereas wrap_get_my_struct_BROKEN returns nonsense.

struct MyStruct:
    e1: decimal
    e2: timestamp


# @dev Construct a MyStruct.
@public
@constant
def get_my_struct(_e1: decimal, _e2: timestamp) -> MyStruct:
    return MyStruct({e1: _e1, e2: _e2})
 

# @dev Wrap self.get_my_struct.
@public
@constant
def wrap_get_my_struct_WORKING(_e1: decimal) -> MyStruct:
    testing: MyStruct = self.get_my_struct(_e1, block.timestamp)
    return testing

# @dev Wrap self.get_my_struct.
@public
@constant
def wrap_get_my_struct_BROKEN(_e1: decimal) -> MyStruct:
    return self.get_my_struct(_e1, block.timestamp)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug that shouldn't change language semantics when fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions