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

Fix return optimization for nested tuple #2392

Merged
merged 2 commits into from
Jul 23, 2021

Conversation

charles-cooper
Copy link
Member

The optimization for tuples of base types expected anything inside a
tuple to be an int, but that's not always the case.

Luckily logic introduced in 0605abb can actually be generalized to any
tuple type which has no dynamic data in the ABI encoding, so we just
remove the constraints on the child types.

What I did

Fixes #2390

How I did it

How to verify it

Compile the example in #2390.

Description for the changelog

Fix type error when returning nested tuples.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

The optimization for tuples of base types expected anything inside a
tuple to be an int, but that's not always the case.

Luckily logic introduced in 0605abb can actually be generalized to any
tuple type which has no dynamic data in the ABI encoding, so we just
remove the constraints on the child types.
@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2021

Codecov Report

Merging #2392 (cae5490) into master (db2606d) will decrease coverage by 0.96%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2392      +/-   ##
==========================================
- Coverage   85.84%   84.88%   -0.97%     
==========================================
  Files          91       91              
  Lines        9022     9022              
  Branches     2152     2152              
==========================================
- Hits         7745     7658      -87     
- Misses        785      866      +81     
- Partials      492      498       +6     
Impacted Files Coverage Δ
vyper/old_codegen/return_.py 100.00% <100.00%> (ø)
vyper/builtin_functions/functions.py 83.12% <0.00%> (-5.63%) ⬇️
vyper/semantics/types/value/numeric.py 80.43% <0.00%> (-5.44%) ⬇️
vyper/old_codegen/expr.py 75.98% <0.00%> (-4.51%) ⬇️
vyper/semantics/types/function.py 86.02% <0.00%> (-2.21%) ⬇️
vyper/old_codegen/global_context.py 66.92% <0.00%> (-1.73%) ⬇️
vyper/ast/nodes.py 92.12% <0.00%> (-1.47%) ⬇️
vyper/semantics/validation/data_positions.py 90.00% <0.00%> (+3.33%) ⬆️

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 db2606d...cae5490. Read the comment docs.

Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for returning a tuple of differnet structs

@charles-cooper
Copy link
Member Author

Please add a test for returning a tuple of differnet structs

@fubuloubu see cae5490 and #2394 (latter explains why I didn't just include the original test cases as is)

@charles-cooper charles-cooper merged commit d8565e7 into vyperlang:master Jul 23, 2021
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.

Compiler error when function returns tuple containing structs
4 participants