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

Improve exception for incorrect arg count #2178

Merged

Conversation

iamdefinitelyahuman
Copy link
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

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.

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.

A couple more branches need tests

@codecov-io
Copy link

codecov-io commented Oct 10, 2020

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.

None yet

4 participants