From 987ac819a927225f1c20c834d15c21f1491a8515 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 31 Jul 2021 18:36:18 +0100 Subject: [PATCH] Use a list instead of a set for storing the potential package imports. This eliminates some indeterminism in the error messages, which was causing occasional failures in CI. We don't expect this list to be very large, so the O(n) insertion time should not be a problem. (cherry picked from commit 389e2a3a946bdae636bf69d5374afda2d8dbeb01) --- PScope.h | 2 +- pform.cc | 2 +- pform_package.cc | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/PScope.h b/PScope.h index 21f751601..2a6d1367e 100644 --- a/PScope.h +++ b/PScope.h @@ -71,7 +71,7 @@ class LexicalScope { // Packages that are wildcard imported. When identifiers from // these packages are referenced, they will be added to the // explicit imports (IEEE 1800-2012 26.3). - std::setpotential_imports; + std::listpotential_imports; // A task or function call may reference a task or function defined // later in the scope. So here we stash the potential imports for diff --git a/pform.cc b/pform.cc index 92a2c65d2..65dc72e15 100644 --- a/pform.cc +++ b/pform.cc @@ -478,7 +478,7 @@ static PPackage*find_potential_import(const struct vlltype&loc, LexicalScope*sco assert(scope); PPackage*found_pkg = 0; - for (set::const_iterator cur_pkg = scope->potential_imports.begin(); + for (list::const_iterator cur_pkg = scope->potential_imports.begin(); cur_pkg != scope->potential_imports.end(); ++cur_pkg) { PPackage*search_pkg = *cur_pkg; map::const_iterator cur_sym diff --git a/pform_package.cc b/pform_package.cc index 2d1017999..e15dab7c5 100644 --- a/pform_package.cc +++ b/pform_package.cc @@ -124,10 +124,12 @@ void pform_package_import(const struct vlltype&loc, PPackage*pkg, const char*ide scope->explicit_imports[use_ident] = pkg; } else { - set::const_iterator cur_pkg - = scope->potential_imports.find(pkg); + list::const_iterator cur_pkg + = find(scope->potential_imports.begin(), + scope->potential_imports.end(), + pkg); if (cur_pkg == scope->potential_imports.end()) - scope->potential_imports.insert(pkg); + scope->potential_imports.push_back(pkg); } }