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[lang]: show user error in error map #4286

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

sandbubbles
Copy link
Collaborator

What I did

Fix #4199

How I did it

Moved error message to "revert"

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

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

raise "some error"
"""
error_map = compile_code(code, output_formats=["source_map"])["source_map"]["error_map"]
assert "user revert with reason" in list(error_map.values())
Copy link
Collaborator

Choose a reason for hiding this comment

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

why can't we check in error_map.values()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can. test_error_map also wraps the values in list - should I change it there too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's a dict view, i think we should. @charles-cooper do you remember the reason you did it this way?

Copy link
Member

Choose a reason for hiding this comment

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

it's a dict view, i think we should. @charles-cooper do you remember the reason you did it this way?

no, just habit i think

vyper/codegen/stmt.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 45.96%. Comparing base (990a6fa) to head (861e6fd).

Files with missing lines Patch % Lines
vyper/codegen/stmt.py 0.00% 3 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (990a6fa) and HEAD (861e6fd). Click for more details.

HEAD has 138 uploads less than BASE
Flag BASE (990a6fa) HEAD (861e6fd)
139 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4286       +/-   ##
===========================================
- Coverage   91.40%   45.96%   -45.45%     
===========================================
  Files         112      112               
  Lines       15920    15922        +2     
  Branches     2693     2693               
===========================================
- Hits        14552     7318     -7234     
- Misses        934     8045     +7111     
- Partials      434      559      +125     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return IRnode.from_list(ir_node, error_msg="user revert with reason")

ir_node = IRnode.from_list(ir_node)
ir_node.set_error_msg("user revert with reason")
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if some of the arguments have their own error message? Then it gets overwritten although it might be more specific.

eg in the case of raise self.bar(5 % i) the mod is annotated with a safemod error msg, which will be replaced with user revert with reason

Copy link
Member

Choose a reason for hiding this comment

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

Hmm I did implement set_error_msg to override, but that could be changed. @sandbubbles could you change that in this PR to not override? And add @cyberthirst's test case raise self.foo(5%i) to the test suite.

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.

user errors not appearing in error map
3 participants