Skip to content

fix[lang]: disallow duplicate getter annotations#4623

Merged
charles-cooper merged 3 commits intovyperlang:masterfrom
cyberthirst:fix/duplicate-var-annotations
May 1, 2025
Merged

fix[lang]: disallow duplicate getter annotations#4623
charles-cooper merged 3 commits intovyperlang:masterfrom
cyberthirst:fix/duplicate-var-annotations

Conversation

@cyberthirst
Copy link
Copy Markdown
Collaborator

@cyberthirst cyberthirst commented Apr 30, 2025

What I did

Commit message

state variables with getters can currently compile with
duplicate `public` or `reentrant` annotations, e.g.
`x: public(public(uint256))`. this commit blocks the behavior.

it also adds test cases for this behavior, as well as analogous test
cases for `immutable` and the other location annotations (which are
correctly blocked, but good to have the tests as well).

How to verify it

  • added tests

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (8852a40) to head (8de9680).
⚠️ Report is 54 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4623   +/-   ##
=======================================
  Coverage   92.49%   92.49%           
=======================================
  Files         128      128           
  Lines       18521    18525    +4     
  Branches     3210     3211    +1     
=======================================
+ Hits        17131    17135    +4     
  Misses        945      945           
  Partials      445      445           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


def test_duplicate_public_annotation():
code = """
a: public(public(uint256))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how about transient(transient(uint256))?

or for that matter, transient(constant(immutable(uint256))) 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

added test cases in ce8cd27

@charles-cooper charles-cooper changed the title fix[lang]: fix duplicate variable annotation fix[lang]: disallow duplicate getter annotations Apr 30, 2025
@cyberthirst
Copy link
Copy Markdown
Collaborator Author

updates to the tests are lgtm

@charles-cooper charles-cooper enabled auto-merge (squash) May 1, 2025 11:24
@charles-cooper charles-cooper merged commit be84de7 into vyperlang:master May 1, 2025
159 checks passed
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