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

No element at index #1169

Closed
1 task
ax0 opened this issue Apr 18, 2023 · 0 comments · Fixed by #1171
Closed
1 task

No element at index #1169

ax0 opened this issue Apr 18, 2023 · 0 comments · Fixed by #1171
Assignees
Labels
bug Something isn't working

Comments

@ax0
Copy link
Contributor

ax0 commented Apr 18, 2023

Aim

Run nargo test on the following code:

fn enc<N>(value: [u8; N], value_length: Field) -> ([u8; 32], Field)
{
    constrain value.len() as u8 >= value_length as u8;

    let mut out_value = [0; 32];
    
    if value_length == 0
    {
    	let out = (out_value, value_length);
 	
	out
    }
    else if value_length as u8 < 31
    {
	out_value[0] = 0x80 + value_length as u8;
	
 	for i in 1..value.len()
 	{
 	    out_value[i] = value[i-1];
 	}
	
	let out = (out_value, value_length + 1);

	out
    }
    else
    {
	let out = (out_value, 32);
	out
    }
}

#[test]
fn enc_test()
{
    let val1 = [0xb8,0x8f,0x61,0xe6,0xfb,0xda,0x83,0xfb,0xff,0xfa,0xbe,0x36,0x41,0x12,0x13,0x74,0x80,0x39,0x80,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00];
    let val1_length = 20;

    let enc_val1 = enc(val1,val1_length);

    constrain enc_val1.0 == [0x94,0xb8,0x8f,0x61,0xe6,0xfb,0xda,0x83,0xfb,0xff,0xfa,0xbe,0x36,0x41,0x12,0x13,0x74,0x80,0x39,0x80,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00];
    constrain enc_val1.1 == 21;
}

Expected behavior

The test should successfully pass.

Bug

We get the following error:

The application panicked (crashed).
Message:  No element at index
Location: crates/noirc_evaluator/src/ssa/node.rs:338

To reproduce

  1. Place the above code in a .nr file in a Noir project.
  2. Run nargo test.

Installation method

Compiled from source

Nargo version

nargo 0.4.0 (git version hash: 809b85f, is dirty: true)

@noir-lang/noir_wasm version

No response

@noir-lang/barretenberg version

No response

@noir-lang/aztec_backend version

No response

Additional context

The test successfully passes if the first if branch is omitted.

Submission Checklist

  • Once I hit submit, I will assign this issue to the Project Board with the appropriate tags.
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
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants