From 04bae9b34bfe54728abe90a20276c7dfaa895e72 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 25 Jun 2024 18:36:02 +0100 Subject: [PATCH 1/4] chore: remove panic for unimplemented trait dispatch --- .../noirc_frontend/src/hir/comptime/interpreter.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index ccfd446d6ac..ecab92fcf5c 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -609,10 +609,13 @@ impl<'a> Interpreter<'a> { let rhs = self.evaluate(infix.rhs)?; // TODO: Need to account for operator overloading - assert!( - self.interner.get_selected_impl_for_expression(id).is_none(), - "Operator overloading is unimplemented in the interpreter" - ); + // See https://github.com/noir-lang/noir/issues/4925 + if self.interner.get_selected_impl_for_expression(id).is_some() { + return Err(InterpreterError::Unimplemented { + item: "Operator overloading is unimplemented in the interpreter. See https://github.com/noir-lang/noir/issues/4925".to_string(), + location: infix.operator.location, + }); + } use InterpreterError::InvalidValuesForBinary; match infix.operator.kind { From 612e723a43902feecf3f9708b7cc7a15744cabe8 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:37:57 +0100 Subject: [PATCH 2/4] Update compiler/noirc_frontend/src/hir/comptime/interpreter.rs --- compiler/noirc_frontend/src/hir/comptime/interpreter.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index ecab92fcf5c..b5b3ec45e77 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -609,7 +609,6 @@ impl<'a> Interpreter<'a> { let rhs = self.evaluate(infix.rhs)?; // TODO: Need to account for operator overloading - // See https://github.com/noir-lang/noir/issues/4925 if self.interner.get_selected_impl_for_expression(id).is_some() { return Err(InterpreterError::Unimplemented { item: "Operator overloading is unimplemented in the interpreter. See https://github.com/noir-lang/noir/issues/4925".to_string(), From c8de5f8851152e553d280dd46ccd3315b4be9173 Mon Sep 17 00:00:00 2001 From: jfecher Date: Tue, 25 Jun 2024 12:42:05 -0500 Subject: [PATCH 3/4] Update compiler/noirc_frontend/src/hir/comptime/interpreter.rs --- compiler/noirc_frontend/src/hir/comptime/interpreter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index b5b3ec45e77..a89f3dcbbc6 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -611,7 +611,7 @@ impl<'a> Interpreter<'a> { // TODO: Need to account for operator overloading if self.interner.get_selected_impl_for_expression(id).is_some() { return Err(InterpreterError::Unimplemented { - item: "Operator overloading is unimplemented in the interpreter. See https://github.com/noir-lang/noir/issues/4925".to_string(), + item: "Operator overloading in the interpreter".to_string(), location: infix.operator.location, }); } From 27dec2582a4c4e329ccefd3666db6ec40b5123b4 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:43:33 +0100 Subject: [PATCH 4/4] Update compiler/noirc_frontend/src/hir/comptime/interpreter.rs --- compiler/noirc_frontend/src/hir/comptime/interpreter.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs index a89f3dcbbc6..85aa97f4c89 100644 --- a/compiler/noirc_frontend/src/hir/comptime/interpreter.rs +++ b/compiler/noirc_frontend/src/hir/comptime/interpreter.rs @@ -609,6 +609,7 @@ impl<'a> Interpreter<'a> { let rhs = self.evaluate(infix.rhs)?; // TODO: Need to account for operator overloading + // See https://github.com/noir-lang/noir/issues/4925 if self.interner.get_selected_impl_for_expression(id).is_some() { return Err(InterpreterError::Unimplemented { item: "Operator overloading in the interpreter".to_string(),