Conversation
|
I added a test for It works when running with Edit: For context the panic message is: |
|
Ok, after some testing I've confirmed the panic happens when any of the methods accepting other functions as arguments are used. That is: |
Option<T> to noir stdlibOption<T> to noir stdlib
Is this PR still blocked? |
|
@iAmMichaelConnor it is still blocked since the |
Option<T> to noir stdlibOption<T> to noir stdlib
|
This PR is no longer blocked since the old SSA code was removed. It is ready for review/merge now |
|
FYI I ended up taking a copy of this (thank you) and putting it in aztec-packages (temporarily). I had to make some edits to make it work over user-defined structs |
|
@iAmMichaelConnor what were the issues that arose from using |
vezenovm
left a comment
There was a problem hiding this comment.
This PR looks to me for the most part. I mainly request that we add some comments on what each of the functions are supposed to do (I find that and on Options can be confusing if you are not familiar with Rust).
Seeing Mike's comments now it would be good to check why |
I think I just got scared about using |
|
@iAmMichaelConnor good to know. The docs mention:
And this falls under a similar case where the value is guaranteed not to be used. The last line of the docs also mentions implementing enums like Option using it. Do you think we should re-word the docs to prevent confusion in the future? I think the main misunderstanding is coming from a very strict definition of "unsafe" the docs are using. There the function is "unsafe" because it can be used to generate values that break a struct's internal assumptions. E.g. if we had a struct: // Invariant: `self.first ^ self.second` must hold
struct EitherOr {
first: bool,
second: bool,
}
impl EitherOr {
fn new(first: bool, second: bool) -> Self {
assert(first ^ second);
Self { first, second }
}
}we could use |
|
Ah, ok, I misunderstood. In that case, I'll start using this stdlib Option type, instead of the modified version. Re improving the docs wording. I'd maybe break the two examples (bounded vec and enumerations) into separate paragraphs, and perhaps add some code snippets to illustrate the points more clearly - i.e. to show how I'd also add this Option type as a 3rd example. I know this PR has gone through, but might I suggest the Perhaps also could we add an |
* master: feat!: Support workspaces and package selection on every nargo command (#1992) chore: Make a more clear error for slices passed to std::println (#2113) feat: Implement type aliases (#2112) feat: Add `Option<T>` to noir stdlib (#1781) feat: Format strings for prints (#1952) feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097) fix: Mutating a variable no longer mutates its copy (#2057) fix: Implement `.len()` in Acir-Gen (#2077) chore: clippy fixes (#2101)
|
@iAmMichaelConnor thanks for the feedback, I'll make a follow-up PR to adjust Another option you could try over the |
* master: (50 commits) fix(globals): Accurately filter literals for resolving globals (#2126) feat: Optimize away constant calls to black box functions (#1981) fix: Rename `Option::value` to `Option::_value` (#2127) feat: replace boolean `AND`s with multiplication (#1954) chore: create a `const` to hold the panic message (#2122) feat: Add support for bitshifts by distances known at runtime (#2072) feat: Add additional `BinaryOp` simplifications (#2124) fix: flattening pass no longer overwrites previously mapped condition values (#2117) chore(noirc_driver): Unify crate preparation (#2119) feat!: Support workspaces and package selection on every nargo command (#1992) chore: Make a more clear error for slices passed to std::println (#2113) feat: Implement type aliases (#2112) feat: Add `Option<T>` to noir stdlib (#1781) feat: Format strings for prints (#1952) feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097) fix: Mutating a variable no longer mutates its copy (#2057) fix: Implement `.len()` in Acir-Gen (#2077) chore: clippy fixes (#2101) chore: Update `noir-source-resolver` to v1.1.3 (#1912) chore: Document `GeneratedAcir::more_than_eq_comparison` (#2085) ...
* master: chore: rename `ssa_refactor` module to `ssa` (#2129) chore: Use `--show-output` flag on execution rather than compilation (#2116) fix(globals): Accurately filter literals for resolving globals (#2126) feat: Optimize away constant calls to black box functions (#1981) fix: Rename `Option::value` to `Option::_value` (#2127) feat: replace boolean `AND`s with multiplication (#1954) chore: create a `const` to hold the panic message (#2122) feat: Add support for bitshifts by distances known at runtime (#2072) feat: Add additional `BinaryOp` simplifications (#2124) fix: flattening pass no longer overwrites previously mapped condition values (#2117) chore(noirc_driver): Unify crate preparation (#2119) feat!: Support workspaces and package selection on every nargo command (#1992) chore: Make a more clear error for slices passed to std::println (#2113) feat: Implement type aliases (#2112) feat: Add `Option<T>` to noir stdlib (#1781) feat: Format strings for prints (#1952) feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097) fix: Mutating a variable no longer mutates its copy (#2057) fix: Implement `.len()` in Acir-Gen (#2077)
* master: chore: rename `ssa_refactor` module to `ssa` (#2129) chore: Use `--show-output` flag on execution rather than compilation (#2116) fix(globals): Accurately filter literals for resolving globals (#2126) feat: Optimize away constant calls to black box functions (#1981) fix: Rename `Option::value` to `Option::_value` (#2127) feat: replace boolean `AND`s with multiplication (#1954) chore: create a `const` to hold the panic message (#2122) feat: Add support for bitshifts by distances known at runtime (#2072) feat: Add additional `BinaryOp` simplifications (#2124) fix: flattening pass no longer overwrites previously mapped condition values (#2117) chore(noirc_driver): Unify crate preparation (#2119) feat!: Support workspaces and package selection on every nargo command (#1992) chore: Make a more clear error for slices passed to std::println (#2113) feat: Implement type aliases (#2112) feat: Add `Option<T>` to noir stdlib (#1781) feat: Format strings for prints (#1952) feat(acir_gen): RecursiveAggregation opcode and updates to black box func call generation (#2097) fix: Mutating a variable no longer mutates its copy (#2057) fix: Implement `.len()` in Acir-Gen (#2077)
Description
Problem*
Relates to #988, although this PR does not add
enums in general, nor does it addmatchto Noir. Only theOptiontype is provided along with some helper methods.Summary*
Documentation
This PR requires documentation updates when merged.
Option's fields (valueand_is_some) do not need to be documented, they can be considered private.Additional Context
PR Checklist*
cargo fmton default settings.