-
Notifications
You must be signed in to change notification settings - Fork 51
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
Use correct source code when error happens in library #272
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good fix at first glance!
tests/unitary/test_modules.py
Outdated
@@ -9,3 +9,5 @@ def test_throw(): | |||
c = boa.load(FIXTURES / "module_contract.vy") | |||
with boa.reverts("Error with message"): | |||
c.fail() | |||
with boa.reverts("error message for devs"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are going to use the same line for both errors, we should probably use the kwarg for reverts()
so it's clear what we are testing for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. i noticed a couple other references to compiler_data.source_code
in boa/profiling.py
, we can push those off to later work though.
What I did
The incorrect source code was being sent to
DevReason.at_source_location
.As a result, when the error happened in a library, the contract source code was being parsed, not the library code.
Generally, this meant that dev reasons were not working properly. However, if the contract happened to have invalid code at that line, boa would crash parsing that line. In the case encountered below, the contract line had a multiline string
"""
in this line, which by itself isn't valid code.How I did it
By using the ast source code, not the contract source code, when trying to get the dev reason.
How to verify it
Cute Animal Picture