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

Array equality #1625

Closed
joss-aztec opened this issue Jun 9, 2023 · 12 comments · Fixed by #1704
Closed

Array equality #1625

joss-aztec opened this issue Jun 9, 2023 · 12 comments · Fixed by #1704
Labels
enhancement New feature or request refactor ssa

Comments

@joss-aztec
Copy link
Contributor

Problem

Array equality isn't implemented in the ssa refactor's acir gen. Currently binary ops only support numerics, and not arrays.

Happy Case

The following program should compile (taken from array_neq test):

// Simple example of checking where two arrays are different
fn main(a: [Field; 32], b: [Field; 32]) {
     assert(a != b);
}

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@joss-aztec joss-aztec added enhancement New feature or request refactor ssa labels Jun 9, 2023
@joss-aztec
Copy link
Contributor Author

Also affects integration test 7

@joss-aztec
Copy link
Contributor Author

And test named ecdsa_secp256k1

@joss-aztec
Copy link
Contributor Author

Test named generics affected.

@joss-aztec
Copy link
Contributor Author

Test named 8_integration affected.

@joss-aztec
Copy link
Contributor Author

Affects test named global_consts

@joss-aztec
Copy link
Contributor Author

7_function

@joss-aztec
Copy link
Contributor Author

Also affects integration test 6

@joss-aztec
Copy link
Contributor Author

strings

@joss-aztec
Copy link
Contributor Author

struct_inputs

@jfecher
Copy link
Contributor

jfecher commented Jun 14, 2023

I'd be in favor of replacing the array equality a1 == a2 in each of these tests with

fn array_eq<T, N>(a1: [T; N], a2: [T; N], elem_eq: fn(T, T) -> bool) -> bool {
    let mut result = true;
    for i in 0 .. a1.len() {
        result &= elem_eq(a1[i], a2[i]);
    }
    result
}

Supporting == for all [T; N] regardless of T as we have now is a type soundness issue anyway.

@joss-aztec
Copy link
Contributor Author

Affects test named keccak256

@joss-aztec
Copy link
Contributor Author

Affects sha256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor ssa
Projects
Archived in project
2 participants