Skip to content
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

[Bug] Aleo variable index array access #2409

Closed
Thormeard opened this issue Mar 25, 2024 · 1 comment
Closed

[Bug] Aleo variable index array access #2409

Thormeard opened this issue Mar 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Thormeard
Copy link

🐛 Bug Report

I am executing an array example from the documentation in snarkvm but it does not work for me. I get this error message: Failed to parse string. Remaining invalid string is: "r0[r1] into r2; output r2; Am I doing something wrong? I am aware that variable index access it is not possible in leo but the documentation is for aleo and it looks like it should work.

https://developer.aleo.org/aleo/language#array

Steps to Reproduce

  1. Take code from the example:
program arraytest.aleo;

function get_array_element:
    input r0 as [boolean; 4u32].public;
    input r1 as u32.public;
    r0[r1] into r2;
    output r2;
  1. And try to execute it (I am using snarkvm execute --offline get_array_element "[true,false,true,false]" 2u32).
    image

If I use constant index it works:

program arraytest.aleo;


function get_array_element:
    input r0 as [boolean; 4u32].public;
    input r1 as u32.public;
    output r0[2u32] as boolean.public;

image

But with variable it is an error:

program arraytest.aleo;


function get_array_element:
    input r0 as [boolean; 4u32].public;
    input r1 as u32.public;
    output r0[r1] as boolean.public;

image

Expected Behavior

Should be possible to access array with a variable index. (or change example in documentation not to confuse people)

Your Environment

  • snarkVM Version: v0.16.19
  • Rust Version: rustc 1.77.0 (aedd173a2 2024-03-17)
  • Computer OS: macOS 14.4
@Thormeard Thormeard added the bug Something isn't working label Mar 25, 2024
@d0cd
Copy link
Contributor

d0cd commented Mar 25, 2024

This is a documentation issue.
Variable index access is not supported in snarkVM.
Tracking issue here: ProvableHQ/welcome#351

@d0cd d0cd closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants