-
Notifications
You must be signed in to change notification settings - Fork 206
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
Add more builtin comptime functions #5668
Labels
enhancement
New feature or request
Comments
This was referenced Aug 1, 2024
Aristotelis2002
pushed a commit
to blocksense-network/noir
that referenced
this issue
Aug 2, 2024
# Description ## Problem Part of noir-lang#5668 ## Summary I originally wanted to just add `type_of`, but in order to test it in some way I thought of comparing two types and checking whether they are equal or not... which required implementing `Eq` for `Type`, which I guess is useful any way. ## Additional Context Another way could have been to be able to turn a `Type` into a string and check that, but there's no unbounded `String` type at comptime... Another way would be to `println` the type and check the program's output, but there's no quick way to do it right now... but I think asserting on equality is fine too, especially because the implementation of `type_of` is very simple. ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 2, 2024
# Description ## Problem Part of #5668 ## Summary I could have added more, but I'll try to keep these PRs relatively small, also to get feedback on the approach. ## Additional Context None. ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
5 tasks
Aristotelis2002
pushed a commit
to blocksense-network/noir
that referenced
this issue
Aug 5, 2024
…stant`, `is_bool` (noir-lang#5678) # Description ## Problem Part of noir-lang#5668 ## Summary I'm leaving `as_struct` for a next PR. ## Additional Context None. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
This was referenced Aug 5, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 5, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context None. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 5, 2024
…rn_type` and `impl Eq for Quoted` (#5681) # Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
This was referenced Aug 6, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 7, 2024
# Description ## Problem Part of #5668 ## Summary Adds these comptime functions: - `Quoted::as_module` - `Module::name` - `Module::is_contract` - `Module::functions` - `FunctionDefinition::name` ## Additional Context Some notes: - I made `Quoted::as_module` return `Option<ModuleId>`, while other `Quoted::as_...` methods currently return a non-Option instead. Eventually it would be nice to unify these but doing that in this PR would have made it much bigger and complex, mainly because those methods rely on methods that are used in many places in the compiler. - For now I made `Module::name` and `FunctionDefinition::name` return `Quoted`. Once we have a `String` type we could change them to `String`, and the logic from going to Quoted -> String is very simple. I was wondering... would a `String` type be what a Slice is for Arrays? One more thought: I wonder if instead of returning `Option<ModuleId>` it wouldn't be better to return some kind of `Result`. That way the caller would know what the error is, if it happens. But I think we don't have `Result` yet in Noir, right? ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 8, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context I think we are missing a `FunctionDefinition::body`, but that could come later. I had to get a `FuncMeta` many times in some functions because Rust wouldn't let me get two mutable borrows of interner. Generics handling is missing... but I think right now generics can't appear in these functions, as attributes only run on top-level functions, not on impl or trait impl functions, but let me know if this is not the case. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 9, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 12, 2024
# Description ## Problem Part of #5668 ## Summary What the title says. ## Additional Context I didn't know how to test the exprs. I tried implementing `impl Eq for Expr` but even though two exprs looked the same (same tokens) they weren't equal... but I didn't dig deeper into why that is (I didn't know if `Eq` was desired in this case) ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 13, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context I thought about adding some `TraitImpl` methods but given that this introduces a new type and a new value I wanted to get feedback on that approach first. There's also a TODO that needs to be addressed. ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 14, 2024
…5722) # Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 15, 2024
… `as_if` (#5726) # Description ## Problem Part of #5668 ## Summary Just four, to keep PRs small. ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 15, 2024
# Description ## Problem Part of #5668 ## Summary Just one method because while doing it I got an error trying to compare two bools at comptime, and I found that that case was missing. ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 22, 2024
# Description ## Problem Part of #5668 ## Summary Introduces `UnresolvedType` from one of Expr variants (cast) and adds `UnresolvedType::is_field` just to assert something about the returned type. ## Additional Context None. ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 26, 2024
# Description ## Problem Part of #5668 ## Summary Also starts wrapping `LValue` too as an `Expr`, and makes `Expr::as_member_access` work for the LValue that looks like a member access. ## Additional Context It seems the last commit of the previous PR didn't go out (sometimes git will do that to me, not sure why) so it's included here. ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 26, 2024
# Description ## Problem Part of #5668 ## Summary Also moves the tests to a test program to avoid evaluating that `comptime` code on each compilation (see #5806) ## Additional Context The rest of the comptime methods involve `Path` or `Pattern` and I'd like to handle those (or one of those) in a separate PR. ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 28, 2024
# Description ## Problem Part of #5668 ## Summary Also allows `quote { ... }.as_expr()` to work with statements and L-values. Then adds an example that injects a `_context: Context` parameter to functions annotated with `#[aztec]`, and to calls inside those functions (any call for now). Also adds an incomplete `Expr::map` to help doing this. Oh, and allows unquoting `Value::Expr`, which wasn't possible before. ## Additional Context A lot is remaining, but I thought this was a good cutting point. Next I might work on #5828 because debugging comptime code without it is tricky. I didn't add docs for `Expr::map` yet as it's still not fully functional. I'll add them once it works for in all cases. ## Documentation Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [x] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 29, 2024
# Description ## Problem Part of #5668 ## Summary Adds `Expr::as_assert` and handles it in `Expr::mutate`. ## Additional Context None. ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 29, 2024
) # Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
This was referenced Aug 30, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 30, 2024
# Description ## Problem Part of #5668 ## Summary Adds `FunctionDef::has_named_attributes` and also changes `Expr::resolve` to take an optional `FunctionDefinition` so you can resolve it relative to another function. ## Additional Context Now the `inject_context` macro works like it needs to for Aztec-Packages!... with the caveat that not all expressions are currently handled in `Expr::mutate` yet. ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 30, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 2, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 9, 2024
# Description ## Problem Part of #5668 ## Summary Adds `Expr::as_let`, but also introduces a new `ExprValue` for patterns, their inlining code, etc. ## Additional Context I wonder if `Pattern` should be an `Expr` or something else, because it can't be converted to an expression like a statement or like an LValue 🤔 ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
This was referenced Sep 9, 2024
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 10, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 13, 2024
# Description ## Problem Part of #5668 ## Summary Also add doc comments for `expr.nr`. ## Additional Context I wasn't sure how to represent a `Path`... so I did it with a `Quoted` value. I first thought about using a `Variable`, but then that wouldn't be parsed right when parsing a constructor, so it had to be some kind of Path. ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher <[email protected]>
5 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 13, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Sep 16, 2024
# Description ## Problem Part of #5668 ## Summary ## Additional Contex ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
github-merge-queue bot
pushed a commit
that referenced
this issue
Oct 7, 2024
# Description ## Problem Part of #5668 ## Summary Work in progress.... (I'll add a bunch of methods in one go) ## Additional Context ## Documentation Check one: - [ ] No documentation needed. - [x] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Maxim Vezenov <[email protected]> Co-authored-by: Tom French <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Here's a list of comptime functions we should implement:
TraitImpl::add_method(self, method: Quoted)
poseidon2_permutation
is implementedMissing variants that map to Expr:
Missing variants that map to Type:
Missing variants that map to UnresolvedType:
Happy Case
The comptime functions above are implemented.
Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: