Skip to content

feat[lang]!: make immutable accessed through self#5035

Open
Sporarum wants to merge 1 commit into
vyperlang:masterfrom
Sporarum:immutables-with-self
Open

feat[lang]!: make immutable accessed through self#5035
Sporarum wants to merge 1 commit into
vyperlang:masterfrom
Sporarum:immutables-with-self

Conversation

@Sporarum

@Sporarum Sporarum commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

What I did

closes: #2695

How I did it

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7d97cdb9a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +261 to +263
self_assigns = constructor.ast_def.get_descendants(
vy_ast.Assign, {"target.value.id": "self"}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject augmented writes to immutables

When a constructor assigns a numeric immutable and then updates it with self.VALUE += 1, this validator only counts Assign nodes, while FunctionAnalyzer.visit_AugAssign still permits CODE-location writes inside constructors. That lets an immutable be modified after its required assignment, bypassing the single-assignment rule that this commit is trying to preserve for self.VALUE = ... duplicates.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure the previous system caught that either, but will fix

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.

yes it did

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.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

📊 Bytecode Size Changes (venom)

No changes detected.

Full bytecode sizes

Contract legacy-O2 legacy-Os -O2 -O3 -Os
curvefi/amm/stableswap/meta_implementation/meta_implementation_v_700.vy 23610 22805 20801 19770 19330
curvefi/legacy/CurveStableSwapMetaNG.vy 24952 23578 20644 20025 19329
curvefi/amm/stableswap/implementation/implementation_v_700.vy 24962 23769 20467 19596 19048
curvefi/legacy/CurveStableSwapNG.vy 24473 23298 19860 19016 18497
curvefi/amm/tricryptoswap/implementation/implementation_v_200.vy 20724 19959 18018 17516 16959
yearnfi/VaultV3.vy 19972 19063 17017 15131 14477
curvefi/amm/twocryptoswap/implementation/implementation_v_210.vy 17634 16894 15685 15132 14648
curvefi/legacy/CurveCryptoSwap2.vy 18947 18382 15622 15068 14699
yearnfi/VaultV2.vy 16676 15763 13863 13405 12574
curvefi/amm/stableswap/factory/factory_v_100.vy 14558 13978 13250 11856 11829
curvefi/amm/stableswap/views/views_v_120.vy 12784 12368 10291 9734 9853
curvefi/gauge/child_gauge/implementation/implementation_v_110.vy 12338 11561 10270 9775 9182
curvefi/gauge/child_gauge/implementation/implementation_v_100.vy 12017 11249 9998 9502 8920
curvefi/amm/tricryptoswap/math/math_v_200.vy 11189 11126 9506 8143 8410
curvefi/legacy/CurveCryptoMathOptimized3.vy 11188 11125 9505 8143 8410
curvefi/gauge/child_gauge/implementation/implementation_v_020.vy 10665 9947 9013 8565 8028
curvefi/helpers/router/router_v_110.vy 6717 6717 7003 6376 6607
curvefi/amm/tricryptoswap/views/views_v_200.vy 7821 7776 6717 6465 6534
curvefi/registries/metaregistry/metaregistry_v_110.vy 7590 6732 6657 5894 5733
curvefi/helpers/stable_swap_meta_zap/stable_swap_meta_zap_v_100.vy 7302 7067 6540 6173 6275
curvefi/amm/twocryptoswap/views/views_v_200.vy 6991 6946 6274 6028 6091
curvefi/registries/metaregistry/registry_handlers/stableswap/handler_v_110.vy 6633 6259 5859 5094 5562
curvefi/amm/tricryptoswap/factory/factory_v_200.vy 5246 5021 5816 4849 4953
curvefi/amm/twocryptoswap/factory/factory_v_200.vy 5540 5252 5816 4579 4740
curvefi/amm/twocryptoswap/math/math_v_210.vy 6800 6800 5581 5107 5112
curvefi/gauge/child_gauge/factory/factory_v_201.vy 4844 4547 4266 4014 3780
yearnfi/VaultFactory.vy 3765 3617 3901 2453 2913
curvefi/registries/metaregistry/registry_handlers/tricryptoswap/handler_v_110.vy 4241 3939 3838 3547 3547
curvefi/registries/metaregistry/registry_handlers/twocryptoswap/handler_v_110.vy 4186 3884 3777 3417 3433
curvefi/gauge/child_gauge/factory/factory_v_100.vy 4183 3914 3694 3428 3213
curvefi/helpers/rate_provider/rate_provider_v_101.vy 3260 3260 2807 2465 2478
curvefi/registries/address_provider/address_provider_v_201.vy 2973 2782 2719 2575 2430
curvefi/amm/stableswap/math/math_v_100.vy 3067 3046 2598 2403 2423
curvefi/helpers/rate_provider/rate_provider_v_100.vy 2847 2841 2373 2066 2074
curvefi/helpers/deposit_and_stake_zap/deposit_and_stake_zap_v_100.vy 2322 2316 2123 1889 1921
curvefi/governance/relayer/taiko/relayer_v_001.vy 2068 2064 1647 1532 1565
curvefi/governance/relayer/polygon_cdk/relayer_v_101.vy 1556 1523 1454 1362 1363
curvefi/governance/relayer/arb_orbit/relayer_v_101.vy 1266 1262 1147 1081 1112
curvefi/governance/relayer/op_stack/relayer_v_101.vy 1186 1182 1086 1023 1051
curvefi/governance/relayer/not_rollup/relayer_v_100.vy 1168 1153 1075 1018 1030
curvefi/governance/vault/vault_v_100.vy 964 941 885 866 864
curvefi/governance/relayer/relayer_v_100.vy 496 496 467 462 467
curvefi/governance/agent/agent_v_100.vy 541 541 443 415 419
curvefi/governance/agent/agent_v_101.vy 541 541 443 415 419

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.86%. Comparing base (b33e733) to head (e7d97cd).

Files with missing lines Patch % Lines
vyper/semantics/analysis/module.py 86.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5035      +/-   ##
==========================================
- Coverage   92.92%   92.86%   -0.07%     
==========================================
  Files         188      188              
  Lines       27820    27832      +12     
  Branches     4828     4831       +3     
==========================================
- Hits        25853    25846       -7     
- Misses       1316     1331      +15     
- Partials      651      655       +4     

☔ View full report in Codecov by Harness.
📢 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.

raise ImmutableViolation(
"Immutable value cannot be modified after assignment"
)
info.var_info._modification_count += 1

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.

uhhhhhh why was this entire (correct) section removed?

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.

why are the tests passing while this correct section was removed? we need to add a test for this case!

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.

btw, for this PR you can ignore the failing gas-bench CI run as this is a breaking change which is currently incompatible with the latest snekmate version.

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.

VIP: immutables should be prefixed with self

3 participants