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[ux]: fix uses error message #3926

Merged
merged 5 commits into from
Apr 10, 2024

Conversation

charles-cooper
Copy link
Member

What I did

How I did it

How to verify it

Commit message

when a stateless module is accidentally declared as being `used` by a
user, the error message is confusing. update the error message to
clarify `uses` refers to state being used.

Description for the changelog

Cute Animal Picture

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

when a stateless module is accidentally declared as being `used` by a
user, the error message is confusing. update the error message to
clarify `uses` refers to state being used.
@charles-cooper charles-cooper marked this pull request as ready for review April 9, 2024 11:12
@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.77%. Comparing base (b43ffac) to head (a3bc9b4).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3926      +/-   ##
==========================================
- Coverage   90.94%   90.77%   -0.17%     
==========================================
  Files          95       95              
  Lines       14397    14397              
  Branches     3191     3191              
==========================================
- Hits        13093    13069      -24     
- Misses        904      927      +23     
- Partials      400      401       +1     

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

@cyberthirst
Copy link
Collaborator

this is also a bit confusing when lib1 isn't used in lib2:

# main
import lib1
import lib2

initializes: lib2
initializes: lib1

@external
def foo():
    lib2.foo()
    lib2.lib1.counter = 1
    
# lib1
counter: uint256

# lib2
import lib1

counter: uint256

@internal
def foo():
    pass
Error compiling: tests/custom/test.vy
vyper.exceptions.ImmutableViolation: Cannot access `lib1` state!

  (hint: add `uses: lib1` or `initializes: lib1` as a top-level statement to your contract)

  contract "tests/custom/test.vy:10", function "foo", line 10:4 
        9     lib2.foo()
  ---> 10     lib2.lib1.counter = 1
  ------------^

could we warn about unused imports?

@pcaversaccio
Copy link
Collaborator

pcaversaccio commented Apr 10, 2024

could we warn about unused imports?

Fwiw, some time ago (~1 year ago lol), I already opened an issue re this #3272.

@charles-cooper charles-cooper enabled auto-merge (squash) April 10, 2024 17:15
@charles-cooper charles-cooper merged commit 8697519 into vyperlang:master Apr 10, 2024
148 checks passed
electriclilies pushed a commit to electriclilies/vyper that referenced this pull request Apr 27, 2024
when a stateless module is accidentally declared as being `used` by a
user, the error message is confusing. update the error message to
clarify `uses` refers to state being used.
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.

4 participants