Skip to content

fix[lang]: use correct DataLocation for internal function args#4835

Open
frederikgramkortegaard wants to merge 3 commits intovyperlang:masterfrom
frederikgramkortegaard:master
Open

fix[lang]: use correct DataLocation for internal function args#4835
frederikgramkortegaard wants to merge 3 commits intovyperlang:masterfrom
frederikgramkortegaard:master

Conversation

@frederikgramkortegaard
Copy link
Contributor

@frederikgramkortegaard frederikgramkortegaard commented Feb 3, 2026

_parse_args was hardcoding CALLDATA for all functions, but internal function arguments live in memory. Added visibility parameter to select the correct location.

Fixes #4754

What I did

Fixed _parse_args to use the correct DataLocation when validating function argument types. Internal functions now correctly check against MEMORY instead of CALLDATA.

How I did it

Added a visibility parameter to _parse_args (defaults to EXTERNAL to avoid changing parameter order). When visibility is INTERNAL we use DataLocation.MEMORY otherwise we uses DataLocation.CALLDATA.

How to verify it

@internal
def _foo(x: HashMap[uint256, uint256]) -> uint256:
    return x[0]

Before: HashMap[uint256, uint256] is not instantiable in calldata
After: HashMap[uint256, uint256] is not instantiable in memory

Commit message

fix: use correct DataLocation for internal function args

Description for the changelog

Fixed incorrect error messages for internal function arguments - now correctly reports "memory" instead of "calldata"

Cute Animal Picture

baby turtle

_parse_args was hardcoding CALLDATA for all functions, but internal
function arguments live in memory. Added visibility parameter to
select the correct location.

Fixes vyperlang#4754
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.91%. Comparing base (3e3ef97) to head (1970e52).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4835   +/-   ##
=======================================
  Coverage   92.91%   92.91%           
=======================================
  Files         156      156           
  Lines       21812    21815    +3     
  Branches     3902     3903    +1     
=======================================
+ Hits        20267    20270    +3     
  Misses       1023     1023           
  Partials      522      522           

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

@frederikgramkortegaard frederikgramkortegaard changed the title fix: use correct DataLocation for internal function args fix[lang]: use correct DataLocation for internal function args Feb 6, 2026
funcdef: vy_ast.FunctionDef, is_interface: bool = False
funcdef: vy_ast.FunctionDef,
is_interface: bool = False,
visibility: FunctionVisibility = FunctionVisibility.EXTERNAL,
Copy link
Member

Choose a reason for hiding this comment

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

it's ok to change the arg order here btw

Copy link
Member

Choose a reason for hiding this comment

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

@frederikgramkortegaard can you move visibility to be a positional arg, i'd like it to be required at the call site

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 fine, please add a test for this

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.

parse_args assumes calldata location for type_from_annotation call

2 participants