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

Use correct source code when error happens in library #272

Merged
merged 4 commits into from
Aug 5, 2024

Conversation

DanielSchiavini
Copy link
Collaborator

@DanielSchiavini DanielSchiavini commented Aug 5, 2024

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

image

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.

Looks like a good fix at first glance!

@@ -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"):
Copy link
Member

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

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.

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.

@charles-cooper charles-cooper merged commit 0d68e95 into master Aug 5, 2024
5 of 8 checks passed
@charles-cooper charles-cooper deleted the dev-reason-parse-error branch August 5, 2024 05:34
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.

2 participants