Skip to content

Improved for loop TypeMismatch exception#2119

Merged
fubuloubu merged 4 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-for-loop-exceptions
Jul 26, 2020
Merged

Improved for loop TypeMismatch exception#2119
fubuloubu merged 4 commits into
vyperlang:masterfrom
iamdefinitelyahuman:feat-for-loop-exceptions

Conversation

@iamdefinitelyahuman

Copy link
Copy Markdown
Contributor

What I did

Improve exception on a failed for loop type check.

How I did it

When the target value in a for loop has multiple potential types, and using each type creates a different TypeMismatch, display all of the exceptions with an explanation as to what happened.

To do so, I've modified the nodes member of VyperException to be called annotations - it can now also be given as a tuple of ("message", node). This lets us attach specific messages to each annotation. I think there will be other places this is useful in the future.

How to verify it

Run tests.

Cute Animal Picture

image

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #2119 into master will decrease coverage by 1.20%.
The diff coverage is 73.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2119      +/-   ##
==========================================
- Coverage   85.01%   83.81%   -1.21%     
==========================================
  Files          83       83              
  Lines        8288     8234      -54     
  Branches     2001     2002       +1     
==========================================
- Hits         7046     6901     -145     
- Misses        743      833      +90     
- Partials      499      500       +1     
Impacted Files Coverage Δ
vyper/context/validation/local.py 88.38% <40.00%> (-0.70%) ⬇️
vyper/exceptions.py 93.51% <80.95%> (-2.56%) ⬇️
vyper/ast/annotation.py 85.96% <0.00%> (-7.90%) ⬇️
vyper/context/types/value/numeric.py 77.50% <0.00%> (-6.65%) ⬇️
vyper/functions/functions.py 83.83% <0.00%> (-5.88%) ⬇️
vyper/parser/expr.py 71.54% <0.00%> (-5.22%) ⬇️
vyper/ast/nodes.py 92.00% <0.00%> (-1.66%) ⬇️
vyper/functions/convert.py 73.46% <0.00%> (-1.37%) ⬇️
vyper/functions/signatures.py 67.24% <0.00%> (-0.56%) ⬇️
vyper/parser/context.py 90.80% <0.00%> (-0.41%) ⬇️
... and 8 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 0de88b7...ff2e976. Read the comment docs.

@fubuloubu fubuloubu merged commit 7dc36d8 into vyperlang:master Jul 26, 2020
@iamdefinitelyahuman iamdefinitelyahuman deleted the feat-for-loop-exceptions branch July 26, 2020 20:26
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.

3 participants