Skip to content

Improve exception for incorrect arg count#2178

Merged
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:invalid-arg-count-exception
Oct 10, 2020
Merged

Improve exception for incorrect arg count#2178
fubuloubu merged 3 commits into
vyperlang:masterfrom
iamdefinitelyahuman:invalid-arg-count-exception

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

What I did

Improve the annotation location and exception message when calling a function with an incorrect number of arguments.

Before:

vyper.exceptions.ArgumentException: Invalid argument count: expected 2, got 3
  function "foo", line 7:4 
       6 def foo(a: address):
  ---> 7     ERC20(a).transfer(a, 2000, 123)
  -----------^
       8

After:

vyper.exceptions.ArgumentException: Invalid argument count for call to 'transfer': expected 2, got 3
  function "foo", line 7:31 
       6 def foo(a: address):
  ---> 7     ERC20(a).transfer(a, 2000, 123)
  --------------------------------------^
       8

How I did it

Prior to raising the exception, look at the node in question and target one of it's descendants accordingly.

Cute Animal Picture

image

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #2178 into master will decrease coverage by 0.92%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2178      +/-   ##
==========================================
- Coverage   85.32%   84.40%   -0.93%     
==========================================
  Files          83       83              
  Lines        8403     8417      +14     
  Branches     2032     2038       +6     
==========================================
- Hits         7170     7104      -66     
- Misses        731      808      +77     
- Partials      502      505       +3     
Impacted Files Coverage Δ
vyper/ast/validation.py 67.44% <78.57%> (+5.37%) ⬆️
vyper/context/types/value/numeric.py 78.04% <0.00%> (-6.10%) ⬇️
vyper/functions/functions.py 84.37% <0.00%> (-5.35%) ⬇️
vyper/parser/expr.py 72.13% <0.00%> (-4.92%) ⬇️
vyper/ast/nodes.py 92.30% <0.00%> (-1.54%) ⬇️

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 a0c561c...458d2b2. Read the comment docs.

@fubuloubu fubuloubu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple more branches need tests

@iamdefinitelyahuman iamdefinitelyahuman force-pushed the invalid-arg-count-exception branch from 458d2b2 to 42b55f4 Compare October 10, 2020 00:55
@codecov-io

codecov-io commented Oct 10, 2020

Copy link
Copy Markdown

Codecov Report

Merging #2178 into master will increase coverage by 0.07%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2178      +/-   ##
==========================================
+ Coverage   85.36%   85.44%   +0.07%     
==========================================
  Files          79       83       +4     
  Lines        8250     8445     +195     
  Branches     2010     2042      +32     
==========================================
+ Hits         7043     7216     +173     
- Misses        709      727      +18     
- Partials      498      502       +4     
Impacted Files Coverage Δ
vyper/ast/validation.py 67.44% <78.57%> (+5.37%) ⬆️
vyper/__main__.py 0.00% <0.00%> (ø)
vyper/typing.py 100.00% <0.00%> (ø)
vyper/opcodes.py 100.00% <0.00%> (ø)
vyper/exceptions.py 93.51% <0.00%> (ø)

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 ce85d7d...42b55f4. Read the comment docs.

@fubuloubu fubuloubu merged commit a81baeb into vyperlang:master Oct 10, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the invalid-arg-count-exception branch December 4, 2020 10:33
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.

4 participants