diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index 897cf1b7b..b66825cd2 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -9,12 +9,8 @@ use rustpython_parser::ast::{Expr, ExprKind, Stmt, StmtKind}; impl<'ctx> CodeGenContext<'ctx> { fn gen_var(&mut self, ty: Type) -> PointerValue<'ctx> { + // should we build the alloca in an initial block? let ty = self.get_llvm_type(ty); - let ty = if let BasicTypeEnum::PointerType(ty) = ty { - ty.get_element_type().try_into().unwrap() - } else { - ty - }; self.builder.build_alloca(ty, "tmp") } @@ -76,6 +72,12 @@ impl<'ctx> CodeGenContext<'ctx> { StmtKind::Expr { value } => { self.gen_expr(&value); } + StmtKind::AnnAssign { target, value, .. } => { + if let Some(value) = value { + let value = self.gen_expr(&value); + self.gen_assignment(target, value); + } + } StmtKind::Assign { targets, value, .. } => { let value = self.gen_expr(&value); for target in targets.iter() {