From 1f2578344a4801f17fcb4bb437c2302ba781be55 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Thu, 31 Oct 2024 12:05:07 +1300 Subject: Ensure the root source unit is always merged last This is to prevent the main source of another zero-dependency source unit from being merged before the main source of the root source unit, which would cause a program to immediately enter into library code when run. The root source unit is always the main source code, and other source units are library code. --- src/symbol_resolver.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/symbol_resolver.rs') diff --git a/src/symbol_resolver.rs b/src/symbol_resolver.rs index e19a7bf..38163e3 100644 --- a/src/symbol_resolver.rs +++ b/src/symbol_resolver.rs @@ -199,7 +199,8 @@ impl SymbolResolver { let source_order = { let mut included_source_ids: Vec = Vec::new(); let mut remaining_source_ids: Vec = Vec::new(); - for i in 0..self.source_units.len() { + // Reverse the order so that the root unit is the last to be added. + for i in (0..self.source_units.len()).rev() { remaining_source_ids.push(i); } -- cgit v1.2.3-70-g09d2