Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a523278
initial updates to make assert_message not a string literal
vezenovm Jan 17, 2024
31b6e55
Merge branch 'master' into mv/assert-msg-fmtstr
vezenovm Jan 17, 2024
84ec1bc
working resolution of assert messages and runtime
vezenovm Jan 19, 2024
0a084c4
remove old impl
vezenovm Jan 19, 2024
c581cee
revert debugging changes for brillig inputs
vezenovm Jan 19, 2024
73e48fb
cargo fmt
vezenovm Jan 19, 2024
0c46345
remove old ocmment
vezenovm Jan 19, 2024
1cf135d
cargo clippy and cleanup
vezenovm Jan 19, 2024
3123241
cleanup old comments and initial debugging for brillig assert message
vezenovm Jan 19, 2024
08d8922
improved usage of From trait for ForeignCallResults
vezenovm Jan 19, 2024
3284b99
resolve merge conflicts
vezenovm Jan 19, 2024
83605d8
start switching order of evaluation of resolve_assert_message as to n…
vezenovm Jan 22, 2024
7fdf5be
Merge branch 'master' into mv/assert-msg-fmtstr
vezenovm Jan 22, 2024
f131b96
switch order of execution
vezenovm Jan 23, 2024
f253cd2
update parser tests and some cleanup
vezenovm Jan 23, 2024
e149ede
cargo clippy
vezenovm Jan 23, 2024
8eb77ad
add back debug logs lines that were removed
vezenovm Jan 23, 2024
d0234d2
added compile failure tests
vezenovm Jan 23, 2024
0f0cbe0
move transformation of call expression to resolution rather than have…
vezenovm Jan 23, 2024
845e269
Merge branch 'master' into mv/assert-msg-fmtstr
vezenovm Jan 23, 2024
85a40c4
handle parser rrs
vezenovm Jan 23, 2024
e42cb9c
fix create_mock
vezenovm Jan 23, 2024
ec87b69
move to non-optional expr
vezenovm Jan 23, 2024
bc317a0
clippy
vezenovm Jan 23, 2024
9284490
clear out circuits w/ only brillig
vezenovm Jan 23, 2024
4333637
update compile_empty_success test
vezenovm Jan 24, 2024
9bc00eb
fix format
vezenovm Jan 24, 2024
f3083c8
cleanup resolve assert message
vezenovm Jan 24, 2024
185aba1
update debugger handle_foreign_call
vezenovm Jan 24, 2024
27ea4d9
cargo fmt
vezenovm Jan 24, 2024
0c7ff78
fix frontend tests, but acvm_js tests still failing
vezenovm Jan 24, 2024
720e470
Update tooling/nargo/src/ops/execute.rs
vezenovm Jan 24, 2024
8698083
some initial switches to putting resolve_assert_message under a predi…
vezenovm Jan 30, 2024
8458f83
Merge remote-tracking branch 'origin/mv/assert-msg-fmtstr' into mv/as…
vezenovm Jan 30, 2024
1a3ea85
accept changes
vezenovm Jan 30, 2024
480297a
missing merge edit
vezenovm Jan 30, 2024
8de9539
remove unused imports
vezenovm Jan 30, 2024
86cab04
remove old dbg
vezenovm Jan 30, 2024
7afc317
switch assert_message call instruction to be atomic with SSA and add …
vezenovm Jan 31, 2024
55de71f
cleanup decompose_constrain
vezenovm Jan 31, 2024
3ebc34a
some comment cleanup
vezenovm Jan 31, 2024
c0d3403
remove old comments
vezenovm Jan 31, 2024
49e7118
resolve merge conflicts
vezenovm Jan 31, 2024
9944a83
cargo fmt
vezenovm Jan 31, 2024
282a7d7
reorganize codegen of constrain error
vezenovm Jan 31, 2024
4cd9255
defunc cleanup
vezenovm Jan 31, 2024
9796a1b
cleanup
vezenovm Jan 31, 2024
8579816
cleanup brillig assert message gen:
vezenovm Jan 31, 2024
5170bc1
Merge branch 'master' into mv/assert-msg-fmtstr
vezenovm Jan 31, 2024
ae06f9e
macro errs update
vezenovm Jan 31, 2024
4e4d273
add an expect func to option
vezenovm Jan 31, 2024
4fdf3a9
add option expect method
vezenovm Jan 31, 2024
89929ff
add comment to expect
vezenovm Jan 31, 2024
e516c27
leave option expect for separate branch
vezenovm Jan 31, 2024
b53a2aa
resovle conflicts w/ parent
vezenovm Jan 31, 2024
0c77f8f
Update compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs
vezenovm Jan 31, 2024
5cd9335
fixup git suggestion
vezenovm Jan 31, 2024
c8170f3
use AssertMessageMacro when disable_macros is enabled
vezenovm Jan 31, 2024
ae23e5c
chore: reduce diff and fix clippy warnings
TomAFrench Jan 31, 2024
5e0e198
chore: reduce diff
TomAFrench Jan 31, 2024
fa6b50c
format constrain err better
vezenovm Jan 31, 2024
f5598fe
Update compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs
vezenovm Jan 31, 2024
d3c2f0e
cargo fmt
vezenovm Jan 31, 2024
bb34b45
fix old test updates
vezenovm Jan 31, 2024
819c95a
remove old comment
vezenovm Jan 31, 2024
c62bec8
reduce diff
vezenovm Jan 31, 2024
7eb7581
Merge branch 'mv/assert-msg-fmtstr' into mv/option-expect
vezenovm Jan 31, 2024
4eaaea9
change to only fmtstr accepted for Option expect
vezenovm Jan 31, 2024
7c1778f
document expect
vezenovm Jan 31, 2024
7f174dc
update assert docs
vezenovm Jan 31, 2024
e06ec4b
use f-string for expect in option compile_success_empty test
vezenovm Jan 31, 2024
2dc4805
Merge branch 'mv/assert-msg-fmtstr' into mv/option-expect
vezenovm Jan 31, 2024
7b2ca25
merge conflicts
vezenovm Feb 1, 2024
4e3aa17
reduce diff
vezenovm Feb 1, 2024
335f250
remove unnecessary prover files
vezenovm Feb 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,10 +1038,10 @@ impl<'interner> Monomorphizer<'interner> {
// since they cannot be passed from ACIR into Brillig
if let HirType::Array(size, _) = typ {
if let HirType::NotConstant = **size {
unreachable!("println does not support slices. Convert the slice to an array before passing it to println");
unreachable!("println and format strings do not support slices. Convert the slice to an array before passing it to println");
}
} else if matches!(typ, HirType::MutableReference(_)) {
unreachable!("println does not support mutable references.");
unreachable!("println and format strings do not support mutable references.");
}

let printable_type: PrintableType = typ.into();
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/noir/standard_library/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Returns the wrapped value if `self.is_some()`. Otherwise, returns the given defa

Returns the wrapped value if `self.is_some()`. Otherwise, calls the given function to return a default value.

### expect

Asserts `self.is_some()` with a provided custom message and returns the contained `Some` value. The custom message is expected to be a format string.

### map

If self is `Some(x)`, this returns `Some(f(x))`. Otherwise, this returns `None`.
Expand Down
6 changes: 6 additions & 0 deletions noir_stdlib/src/option.nr
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ impl<T> Option<T> {
}
}

/// Asserts `self.is_some()` with a provided custom message and returns the contained `Some` value
fn expect<N, MessageTypes>(self, message: fmtstr<N, MessageTypes>) -> T {
assert(self.is_some(), message);
self._value
}

/// If self is `Some(x)`, this returns `Some(f(x))`. Otherwise, this returns `None`.
pub fn map<U, Env>(self, f: fn[Env](T) -> U) -> Option<U> {
if self._is_some {
Expand Down
2 changes: 2 additions & 0 deletions test_programs/compile_failure/assert_msg_runtime/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "5"
y = "10"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "5"
7 changes: 7 additions & 0 deletions test_programs/compile_failure/option_expect/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "option_expect"
type = "bin"
authors = [""]
compiler_version = ">=0.23.0"

[dependencies]
8 changes: 8 additions & 0 deletions test_programs/compile_failure/option_expect/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
let inner_value = 3;
let none = Option::none();
let some = Option::some(inner_value);

assert(some.expect(f"Should have the value {inner_value}") == 3);
assert(none.expect(f"Should have the value {inner_value}") == 3);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "option_expect_bad_input"
type = "bin"
authors = [""]
compiler_version = ">=0.23.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
let inner_value = 3;
let some = Option::some(inner_value);

assert(some.expect("Should have the value {inner_value}") == 3);
}
4 changes: 2 additions & 2 deletions test_programs/compile_success_empty/option/src/main.nr
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use dep::std::option::Option;

fn main() {
let ten = 10; // giving this a name, to ensure that the Option functions work with closures
let none = Option::none();
Expand All @@ -22,6 +20,8 @@ fn main() {
assert(some.map(|x| x * 2).unwrap() == 6);
assert(some.map(|x| x * ten).unwrap() == 30);

assert(some.expect(f"Should have a value") == 3);

assert(none.map_or(0, |x| x * 2) == 0);
assert(some.map_or(0, |x| x * 2) == 6);
assert(none.map_or(0, |x| x * ten) == 0);
Expand Down