noir-lang / noir

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

feat: Implement type paths #6093

Closed jfecher closed 1 week ago

jfecher commented 1 week ago

Description

Problem*

Resolves https://github.com/noir-lang/noir/issues/6078

Summary*

Adds the ability to do Type::method where Type is a primitive type or interned type. Other named types should already be supported by existing paths.

Additional Context

I also made a small update to lookup_method to support looking up methods without a self parameter to allow for us to possibly have something like Field::static_method() in the future, although we have no functions like this in the stdlib currently.

Documentation*

Check one:

PR Checklist*

github-actions[bot] commented 1 week ago

Changes to Brillig bytecode sizes

Generated at commit: 58796212d4467483bb46bdcb391f14b7fbcbcd7f, compared to commit: 26d275b65fa339d877c90d5c6c13ac8ef47189e1

There are no changes in circuit sizes

asterite commented 1 week ago

although we have no functions like this in the stdlib currently

When implementing Expr::modify I introduced some new_let, new_if, etc., functions that I originally wrote as static methods of Expr, but then I changed them to regular functions because that didn't work (my idea was to have these new_ functions actually exposed to users in case they wanted to programmatically build expressions, though in the end maybe that's not very useful).