Skip to content

Incorrect Error Location for DynArray Addition #4676

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

Open
benber86 opened this issue Jun 4, 2025 · 0 comments · May be fixed by #4677
Open

Incorrect Error Location for DynArray Addition #4676

benber86 opened this issue Jun 4, 2025 · 0 comments · May be fixed by #4677
Labels
bug - UX a bug related to UX
Milestone

Comments

@benber86
Copy link
Contributor

benber86 commented Jun 4, 2025

Version Information

  • vyper Version (output of vyper --version): 0.4.1
  • OS: linux
  • Python Version (output of python --version): 3.12

What's your issue about?

Vyper incorrectly reports the location of a type error when performing invalid operations on DynArrays. The error points to a constant declaration instead of the actual operation causing the error.

Given the follow contract:

MAX1: constant(uint256) = 10
MAX2: constant(uint256) = MAX1 + 2

@external
def foo(data1: DynArray[address, MAX1]):
    data2: DynArray[address, 2] = [empty(address), empty(address)]
    data3: DynArray[address, MAX2] = data1 + data2

Expected Behavior:

The error should point to line 7 where the actual DynArray addition data1 + data2 is performed.

Actual Behavior:

The error incorrectly points to line 2 at the constant declaration MAX1 + 1, which is a valid uint256 addition operation and not the source of the error.

Error output:

vyper.exceptions.InvalidOperation: Cannot perform addition on DynArray[address, 10]

  contract "test.vy:2", function "foo", line 2:26 
       1 MAX1: constant(uint256) = 10
  ---> 2 MAX2: constant(uint256) = MAX1 + 2
  ---------------------------------^
       3
@benber86 benber86 added the needs triage needs triage label Jun 4, 2025
@charles-cooper charles-cooper added bug - UX a bug related to UX and removed needs triage needs triage labels Jun 4, 2025
@charles-cooper charles-cooper added this to the v0.4.3 milestone Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - UX a bug related to UX
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants