noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
878 stars 190 forks source link

Remove type hierarchy in the SSA #1966

Closed sirasistant closed 1 year ago

sirasistant commented 1 year ago

Problem

Right now in SSA arrays are a subtype of slice. Handling type hierarchy in SSA & codegen makes passes on the code more complicated, so we've decided to remove it keeping type hierarchy in the frontend.

Happy Case

There is only the Slice type in the SSA and we keep track of the length for ACIR execution.

Alternatives Considered

Removing type hierarchy in the frontend (arrays would require an operator or a method call to be converted to slices). This could create worse devex.

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

sirasistant commented 1 year ago

Closing as a duplicate of https://github.com/noir-lang/noir/issues/1963

jfecher commented 1 year ago

I was going to re-open this because #1963 is only about changes to the type system not the SSA but maybe it does fix it in a way I haven't considered before. If functions were polymorphic over whether they took arrays or slices then we'd monomorphize a new version of the function for each. So there wouldn't be any functions after monomorphization that accepted both.