diff --git a/nac3core/src/codegen/mod.rs b/nac3core/src/codegen/mod.rs index d83b22bf4..d4036332c 100644 --- a/nac3core/src/codegen/mod.rs +++ b/nac3core/src/codegen/mod.rs @@ -20,7 +20,7 @@ use inkwell::{ use itertools::Itertools; use nac3parser::ast::{Stmt, StrRef}; use parking_lot::{Condvar, Mutex}; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -206,7 +206,7 @@ impl WorkerRegistry { let passes = PassManager::create(&module); pass_builder.populate_function_pass_manager(&passes); - let mut errors = Vec::new(); + let mut errors = HashSet::new(); while let Some(task) = self.receiver.recv().unwrap() { let tmp_module = context.create_module("tmp"); match gen_func(&context, generator, self, builder, tmp_module, task) { @@ -217,14 +217,14 @@ impl WorkerRegistry { } Err((old_builder, e)) => { builder = old_builder; - errors.push(e); + errors.insert(e); } } *self.task_count.lock() -= 1; self.wait_condvar.notify_all(); } if !errors.is_empty() { - panic!("Codegen error: {}", errors.iter().join("\n----------\n")); + panic!("Codegen error: {}", errors.into_iter().sorted().join("\n----------\n")); } let result = module.verify(); diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 49275072a..f917e4b94 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -464,7 +464,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } Ok(()) } @@ -560,7 +560,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } // second, get all ancestors @@ -591,7 +591,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } // insert the ancestors to the def list @@ -674,7 +674,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } // handle the inheritanced methods and fields @@ -727,7 +727,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } Ok(()) @@ -953,7 +953,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } Ok(()) } @@ -1555,7 +1555,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n---------\n")); + return Err(errors.into_iter().sorted().join("\n---------\n")); } for (i, signature, id) in constructors.into_iter() { @@ -1851,7 +1851,7 @@ impl TopLevelComposer { } } if !errors.is_empty() { - return Err(errors.iter().join("\n----------\n")); + return Err(errors.into_iter().sorted().join("\n----------\n")); } Ok(()) }