diff --git a/examples/loops.reid b/examples/loops.reid index 2c07934..409de52 100644 --- a/examples/loops.reid +++ b/examples/loops.reid @@ -1,12 +1,16 @@ // Arithmetic, function calls and imports! import std::print; -import std::from_str; +import std::new_string; +import std::add_num_to_str; +import std::free_string; fn main() -> u32 { - let text = from_str("hello"); - for i in 0 .. 10 { - print(&text) + for i in 0 .. 5 { + let mut text = new_string(); + add_num_to_str(&mut text, i); + print(&text); + free_string(&mut text); } let mut num = 0; diff --git a/reid/src/ast/process.rs b/reid/src/ast/process.rs index 4929cad..355d323 100644 --- a/reid/src/ast/process.rs +++ b/reid/src/ast/process.rs @@ -186,7 +186,7 @@ impl ast::Block { counter_range.as_meta(module_id), ); let mut block = block.into_mir(module_id); - block.statements.insert(0, set_new); + block.statements.push(set_new); ( StmtKind::While(WhileStatement { condition: mir::Expression(