Fix error

This commit is contained in:
Sofia 2023-08-02 20:17:20 +03:00
parent 91a6485d5a
commit 9710406747
2 changed files with 4 additions and 2 deletions

View File

@ -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 {

View File

@ -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<String, ReidError> {
@ -37,7 +39,7 @@ pub fn compile(source: &str) -> Result<String, ReidError> {
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())