From a850c9bc8d528eef2b27a7c169054155fed45fb1 Mon Sep 17 00:00:00 2001 From: Bobbin Threadbare Date: Mon, 22 Jul 2024 17:38:13 -0700 Subject: [PATCH] refactor: move proc registration to after proc compilation --- assembly/src/assembler/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assembly/src/assembler/mod.rs b/assembly/src/assembler/mod.rs index 47d236844c..b23ae6d36c 100644 --- a/assembly/src/assembler/mod.rs +++ b/assembly/src/assembler/mod.rs @@ -387,6 +387,9 @@ impl Assembler { // Compile this procedure let procedure = self.compile_procedure(pctx, mast_forest_builder)?; + // register the procedure in the MAST forest + mast_forest_builder.make_root(procedure.body_node_id()); + // Cache the compiled procedure, unless it's the program entrypoint if is_entry { compiled_entrypoint = Some(Arc::from(procedure)); @@ -432,8 +435,6 @@ impl Assembler { self.compile_body(proc.iter(), &mut proc_ctx, None, mast_forest_builder)? }; - mast_forest_builder.make_root(proc_body_root); - Ok(proc_ctx.into_procedure(proc_body_root)) }