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 18 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

All modified and coverable lines are covered by tests ✅

Project coverage is 45.57%. Comparing base (e0fc53a) to head (5f2cd05).
Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (e0fc53a) and HEAD (5f2cd05). Click for more details.

HEAD has 136 uploads less than BASE
Flag BASE (e0fc53a) HEAD (5f2cd05)
137 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4286       +/-   ##
===========================================
- Coverage   91.27%   45.57%   -45.71%     
===========================================
  Files         112      112               
  Lines       16017    16017               
  Branches     2696     2696               
===========================================
- Hits        14619     7299     -7320     
- Misses        966     8159     +7193     
- Partials      432      559      +127     

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


🚨 Try these New Features:

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.

Copy link
Member

Choose a reason for hiding this comment

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

does it make sense actually to just call set_error_msg in from_list()? since i imagine the same issue may happen at other call sites?

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

As discussed offline- please check if it is feasible to call set_error_msg in the from_list factory

is_self_call=is_self_call,
passthrough_metadata=passthrough_metadata,
)
if error_msg is not None:
ret.set_error_msg(error_msg)
Copy link
Member

Choose a reason for hiding this comment

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

maybe _set_error_msg, since the IRnode may already have error_msg set

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