Skip to content

fix[lang]: filter oob array access during folding#4571

Merged
charles-cooper merged 5 commits intovyperlang:masterfrom
charles-cooper:fix/oob-folding
Apr 12, 2025
Merged

fix[lang]: filter oob array access during folding#4571
charles-cooper merged 5 commits intovyperlang:masterfrom
charles-cooper:fix/oob-folding

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Apr 11, 2025

constant folding was not filtering out oob array index accesses. this is because it was raising UnfoldableNode, which is caught by the folding machinery. this commit changes it to an ArrayIndexException, which will propagate to the user and abort compilation.

What I did

fix #4436

How I did it

How to verify it

Commit message

constant folding was not filtering out oob array index accesses. this is
because it was raising `UnfoldableNode`, which is caught by the folding
machinery. this commit changes it to an `ArrayIndexException`, which
will propagate to the user and abort compilation.

Description for the changelog

Cute Animal Picture

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

constant folding was not filtering out oob array index accesses. this is
because it was raising `UnfoldableNode`, which is caught by the folding
machinery. this commit changes it to an `ArrayIndexException`, which
will propagate to the user and abort compilation.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.70%. Comparing base (c05c1b9) to head (8cefaa8).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4571      +/-   ##
==========================================
+ Coverage   92.66%   92.70%   +0.04%     
==========================================
  Files         123      123              
  Lines       17516    17526      +10     
  Branches     2967     2971       +4     
==========================================
+ Hits        16231    16248      +17     
+ Misses        883      879       -4     
+ Partials      402      399       -3     

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

failing_list = [
"MAX: constant(DynArray[uint256, 10]) = [1, 2, 3]",
"MAX: constant(uint256[3]) = [1, 2, 3]",
"MAX: constant((uint256, uint256, uint256)) = (1, 2, 3)",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

note that even for tuples we raise ArrayIndexException

@charles-cooper charles-cooper merged commit 2d515d3 into vyperlang:master Apr 12, 2025
161 checks passed
@charles-cooper charles-cooper deleted the fix/oob-folding branch April 12, 2025 07:31
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.

constexpr DynArray subscript gets evaluated at runtime

2 participants