aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler.rs')
-rw-r--r--src/compiler.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler.rs b/src/compiler.rs
index 347abe6..92bf3fc 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -472,6 +472,9 @@ impl Compiler {
let mut return_type = Type::Void;
let mut function_block = Block::new(&name, &self.current_file, self.line());
+ let block_id = self.blocks.len();
+ self.blocks.push(Rc::new(RefCell::new(Block::new(&name, &self.current_file, self.line()))));
+
let _ret = push_frame!(self, function_block, {
loop {
match self.peek() {
@@ -538,8 +541,8 @@ impl Compiler {
let func = Op::Constant(Value::Function(Vec::new(), Rc::clone(&function_block)));
+ self.blocks[block_id] = function_block;
block.add(func, self.line());
- self.blocks.push(function_block);
}
fn variable_expression(&mut self, block: &mut Block) {