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

Tuple Destructuring #376

Closed
g-r-a-n-t opened this issue Apr 28, 2021 · 0 comments · Fixed by #428
Closed

Tuple Destructuring #376

g-r-a-n-t opened this issue Apr 28, 2021 · 0 comments · Fixed by #428
Assignees
Labels
comp: lowering Everything that involves the lowering pass

Comments

@g-r-a-n-t
Copy link
Member

g-r-a-n-t commented Apr 28, 2021

What is wrong?

Users can't destructure tuples.

e.g.

(foo, bar): (u256, bool) = my_tuple

How can it be fixed

Implement destructuring in the lowering pass. The example statement above should be lowered to the following:

foo: u256 = my_tuple.item0
bar: bool = my_tuple.item1

edit: The above lowering would evaluate the expression twice, which is something we need to watch out for.

What we want is something like:

low_tuple: tuple_u256_bool = my_tuple
foo: u256 = low_tuple.item0
bar: bool = low_tuple.item1
@g-r-a-n-t g-r-a-n-t added the comp: lowering Everything that involves the lowering pass label Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: lowering Everything that involves the lowering pass
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants