Skip to content

Allow empty as an argument in a function call#2234

Merged
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:fix-empty
Nov 29, 2020
Merged

Allow empty as an argument in a function call#2234
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:fix-empty

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

What I did

Allow use of empty(Bytes[n]) as an argument within a function call.

Closes #2112

How I did it

  • In vyper.parser.parser_utils::pack_arguments, add a branch of logic to handle empty. Because empty implies a length of 0 bytes, the logic here is very simple: add 64 empty bytes from the end of calldata.
  • As an optimization, I'm also applying the same logic for literal b"" and "". The overhead of the bytes copier is unnecessary in these situations.
  • I've added an optimization where the dynamic pointer is not updated after storing the final dynamic type.

How to verify it

Run the tests. I added some cases.

Cute Animal Picture

image

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #2234 (448a5b6) into master (a222091) will decrease coverage by 1.11%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2234      +/-   ##
==========================================
- Coverage   85.37%   84.25%   -1.12%     
==========================================
  Files          84       84              
  Lines        8552     8494      -58     
  Branches     2066     2069       +3     
==========================================
- Hits         7301     7157     -144     
- Misses        745      831      +86     
  Partials      506      506              
Impacted Files Coverage Δ
vyper/parser/parser_utils.py 81.02% <91.66%> (-0.39%) ⬇️
vyper/ast/annotation.py 87.87% <0.00%> (-6.82%) ⬇️
vyper/context/types/value/numeric.py 77.50% <0.00%> (-6.65%) ⬇️
vyper/functions/functions.py 83.99% <0.00%> (-5.43%) ⬇️
vyper/parser/expr.py 72.58% <0.00%> (-5.02%) ⬇️
vyper/ast/nodes.py 91.80% <0.00%> (-1.58%) ⬇️
vyper/functions/convert.py 73.64% <0.00%> (-1.36%) ⬇️
vyper/context/types/indexable/sequence.py 82.14% <0.00%> (-0.62%) ⬇️
vyper/functions/signatures.py 65.51% <0.00%> (-0.59%) ⬇️
vyper/context/types/meta/struct.py 80.00% <0.00%> (-0.33%) ⬇️
... and 9 more

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 a222091...58adccf. Read the comment docs.

@fubuloubu

Copy link
Copy Markdown
Contributor

you shut your damn mouth codecov-io bot!

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.

empty(Bytes[1024]) causes vyper.exceptions.CompilerPanic: Unsupported location: None

3 participants