-
-
Notifications
You must be signed in to change notification settings - Fork 810
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
Passing arrays to private and public functions #1418
Comments
What version of vyper are you on? |
I tested it with the Vyper plugin in the Remix IDE which seems to be using version 0.1.0b9. |
Thanks - you mentioned your execution ends in an exception, what specific exception are you seeing? |
On closer inspection I found the following: On instruction no 522 (which is an MSTORE) there is only a single value on the operand stack, instead of the required 2. |
This seems like a bug. Trying to reproduce it on my end, in the meantime would it be possible for you to post the code which produces this? Or the IR ( |
The code above (with private instead of public) is all that is needed:
Calling call_arr() triggers the bug. I think the bottom most IR:
|
This seems to be a bug in argument packing (the inner assignment is not needed to trip the issue). The following is a minimal difference between the non-error and error cases @private
def change_arr(arr: int128[2]):
pass
@public
def call_arr() -> int128:
- a: int128[2] = [42,1] # pass
+ a: int128[2] # fail
self.change_arr(a)
return 42 |
An even more subtle test case: @private
def change_arr(arr: int128[2]):
pass
@public
def call_arr() -> int128:
a: int128[2]
+ a[0] = 37 # fail
- a[1] = 37 # pass
self.change_arr(a)
return 42 Difference in IR:
|
Security Alert: if you use arrays as parameters to a private function, on released versions starting at You should upgrade to |
I'm trying to understand how arrays work in Vyper. It seems that they always get copied on assignment. However, I found the following:
As expected, calling the function
call_arr
returns 42. However, if I make the functionchange_arr
private the execution ends in an exception (because ofa[0] = 24
).The text was updated successfully, but these errors were encountered: