diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 45b005f7559..abd24b9f67c 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -186,6 +186,12 @@ pub fn compile_contract( let err = CustomDiagnostic::from_message("Packages are limited to a single contract") .in_file(FileId::default()); return Err(vec![err]); + } else if contracts.is_empty() { + let err = CustomDiagnostic::from_message( + "cannot compile crate into a contract as it does not contain any contracts", + ) + .in_file(FileId::default()); + return Err(vec![err]); }; for contract in contracts {