From 9710406747dffd365e670fdd4815ea8884c1a6ff Mon Sep 17 00:00:00 2001 From: sofia Date: Wed, 2 Aug 2023 20:17:20 +0300 Subject: [PATCH] Fix error --- src/codegen.rs | 2 +- src/lib.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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())