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

Arrays within Structs #1200

Closed
derekzx opened this issue Jan 16, 2019 · 3 comments
Closed

Arrays within Structs #1200

derekzx opened this issue Jan 16, 2019 · 3 comments
Labels
bug Bug that shouldn't change language semantics when fixed.

Comments

@derekzx
Copy link

derekzx commented Jan 16, 2019

Version Information

  • vyper Version: 0.1.0b6
  • OS: Ubuntu 18.04
  • Python Version (python --version): 3.6.7

What's your issue about?

Returning an array within a struct throws error.

I know that structs are currently in Alpha phase but this bug may be helpful when designing tests!

Input

Compilation: vyper test.py

Output:

Error compiling:  test.py
Traceback (most recent call last):
  File "/usr/local/bin/vyper", line 4, in <module>
    __import__('pkg_resources').run_script('vyper==0.1.0b6', 'vyper')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1445, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/EGG-INFO/scripts/vyper", line 85, in <module>
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/compiler.py", line 108, in compile_codes
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/EGG-INFO/scripts/vyper", line 51, in exc_handler
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/compiler.py", line 105, in compile_codes
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/compiler.py", line 87, in <lambda>
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/compiler.py", line 8, in __compile
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 259, in parse_tree_to_lll
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 207, in parse_other_functions
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 571, in parse_func
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 571, in <listcomp>
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 588, in parse_body
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser.py", line 603, in parse_stmt
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/stmt.py", line 80, in __init__
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/stmt.py", line 626, in parse_return
  File "/usr/local/lib/python3.6/dist-packages/vyper-0.1.0b6-py3.6.egg/vyper/parser/parser_utils.py", line 668, in gen_tuple_return
vyper.exceptions.TypeMismatchException: line 69: Can't return type int128[2] as part of tuple
    return G2Point({
----^

Full Code:

struct G2Point:
    X : int128[2]
    Y : int128[2]

@public
def test() -> G2Point:
    return G2Point({
        X : [1,2],
        Y : [2,3]
    })

How can it be fixed?

Fill this in if you know how to fix it.

Cute Animal Picture

image

@derekzx
Copy link
Author

derekzx commented Jan 16, 2019

#1019

@jacqueswww jacqueswww added the bug Bug that shouldn't change language semantics when fixed. label Jan 17, 2019
@charles-cooper
Copy link
Member

Since structs and tuples have the same representation I think this and #955 should be solved with the same implementation.

@fubuloubu fubuloubu added this to To do in v1.0 Release Candidate via automation Oct 24, 2019
@charles-cooper
Copy link
Member

This is fixed in master (I think as of #1723).

v1.0 Release Candidate automation moved this from To do to Done Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that shouldn't change language semantics when fixed.
Projects
Development

No branches or pull requests

3 participants