diff --git a/noir_stdlib/src/lib.nr b/noir_stdlib/src/lib.nr index 81c408c01bc..714079d306a 100644 --- a/noir_stdlib/src/lib.nr +++ b/noir_stdlib/src/lib.nr @@ -28,6 +28,7 @@ mod runtime; mod meta; mod append; mod mem; +mod panic; // Oracle calls are required to be wrapped in an unconstrained function // Thus, the only argument to the `println` oracle is expected to always be an ident diff --git a/noir_stdlib/src/meta/op.nr b/noir_stdlib/src/meta/op.nr index f3060a1648b..1917a04da59 100644 --- a/noir_stdlib/src/meta/op.nr +++ b/noir_stdlib/src/meta/op.nr @@ -39,7 +39,8 @@ impl UnaryOp { } else if self.is_dereference() { quote { * } } else { - crate::mem::zeroed() + let op = self; + crate::panic::panic(f"Unexpected unary operator in UnaryOp::quoted: {op}") } } } @@ -181,7 +182,8 @@ impl BinaryOp { } else if self.is_modulo() { quote { % } } else { - crate::mem::zeroed() + let op = self; + crate::panic::panic(f"Unexpected binary operator in BinaryOp::quoted: {op}") } } } diff --git a/noir_stdlib/src/panic.nr b/noir_stdlib/src/panic.nr new file mode 100644 index 00000000000..833c1f3dcfc --- /dev/null +++ b/noir_stdlib/src/panic.nr @@ -0,0 +1,4 @@ +pub fn panic(message: fmtstr) -> U { + assert(false, message); + crate::mem::zeroed() +} diff --git a/noir_stdlib/src/prelude.nr b/noir_stdlib/src/prelude.nr index b14f38bdf55..b6e54eaae60 100644 --- a/noir_stdlib/src/prelude.nr +++ b/noir_stdlib/src/prelude.nr @@ -7,3 +7,4 @@ pub use crate::cmp::{Eq, Ord}; pub use crate::default::Default; pub use crate::convert::{From, Into}; pub use crate::meta::{derive, derive_via}; +pub use crate::panic::panic;