From 14537743ed73b60dc3ee38b66bc5f5ba79faaa99 Mon Sep 17 00:00:00 2001 From: sofia Date: Wed, 23 Jul 2025 21:16:57 +0300 Subject: [PATCH] Fix for-loops --- examples/loops.reid | 12 ++++++++---- reid/src/ast/process.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) 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(