diff --git a/src/codegen.rs b/src/codegen.rs index 3b20b5d..d45fc30 100644 --- a/src/codegen.rs +++ b/src/codegen.rs @@ -40,7 +40,7 @@ impl TopLevelStatement { let mut scope = Scope::from(module.create_block()); for statement in &block.0 { - statement.codegen(&mut scope); + statement.codegen(&mut scope)?; } let value = if let Some(exp) = &block.1 { diff --git a/src/lib.rs b/src/lib.rs index 3877db9..831c890 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,8 @@ pub enum ReidError { LexerError(#[from] lexer::Error), #[error(transparent)] ParserError(#[from] token_stream::Error), + #[error(transparent)] + CodegenError(#[from] codegen::Error), } pub fn compile(source: &str) -> Result { @@ -37,7 +39,7 @@ pub fn compile(source: &str) -> Result { let mut module = IRModule::new("testmod"); for statement in statements { - statement.codegen(&mut module); + statement.codegen(&mut module)?; } let text = module.print_to_string().unwrap(); Ok(text.to_owned())