Skip to content

Passing arrays to private and public functions #1418

@robinsierra

Description

@robinsierra
  • vyper Version: 0.1.0b9
  • Tested with Remix IDE

I'm trying to understand how arrays work in Vyper. It seems that they always get copied on assignment. However, I found the following:

@public
def change_arr(arr: int128[5]):
    a: int128[5] = arr
    a[0] = 24

@public
def call_arr() -> int128:
    a: int128[5]
    a[0] = 42
    self.change_arr(a)
    return a[0]

As expected, calling the function call_arr returns 42. However, if I make the function change_arr private the execution ends in an exception (because of a[0] = 24).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug that shouldn't change language semantics when fixed.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions