I'm working on a sample game to demonstrate some proof of concepts. Including, showing both versions of the contract (Solidity & Vyper) so i can show a comparison of building and usage.
I'm trying to convert a solidity contract into Vyper.
Can't seem to return the same bag of values.
For the following vyper function :
@public
@constant
def getStoryNode(id: uint256) -> (uint256, bytes[256], bytes[256], address, uint256[256]):
return (self.stories_nodes[id].id, self.stories_nodes[id].title, self.stories_nodes[id].body, self.stories_nodes[id].owner, self.stories_nodes[id].childNodesIds)
I get the following error when compiling the contract:
Exception: ("Can't return type %s as part of tuple", <class 'vyper.types.types.ListType'>)
Solidity Version :
/**
* Returns node's id, title, body, owner's address
*/
function getStoryNode(uint id) public view returns(uint, string, string, address, uint[]) {
StoryNode storage node = storiesNodes[id];
return (node.id, node.title, node.body, node.owner, node.childNodesIds);
}
Can stmt.py::parse_return be improved to handle this? Maybe i can do do this myself and submit PR.
Unless i missed something in the docs... strings & dynamically sized mappings aren't a thing, right?

As long as it's a fixed size list this should be do-able yes. :+1: Tagging as a bug.
@ehanoc could you please test this again, I believe this has been fixed with additional tuple work.
@jacqueswww I wrote a couple small tests to check.
The string vs bytes[] fixes the issues with string types.
Although there could be an issue with int [] as part of the tuple.
@public
def foo() -> (uint256, uint256[2]):
return (0, [0, 1])
Output:
else:
# Maybe this should panic because the type error should be
# caught at an earlier type-checking stage.
> raise TypeMismatchException("Can't return type %s as part of tuple" % arg.typ, stmt)
E vyper.exceptions.TypeMismatchException: line 15: Can't return type int128[2] as part of tuple
E return (0, [0, 1])
E ----^
vyper/parser/parser_utils.py:681: TypeMismatchException
Is this an issue? I might be missing something
Thanks for testing, will have a look ;)
Related to #1019.