File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1- // Copyright 2017-2023 the nyan authors, LGPLv3+. See copying.md for legal info.
1+ // Copyright 2017-2024 the nyan authors, LGPLv3+. See copying.md for legal info.
22
33#include " database.h"
44
@@ -103,6 +103,7 @@ void Database::load(const std::string &filename,
103103 auto it = imports.find (namespace_to_import);
104104 if (it != std::end (imports)) {
105105 // this namespace is already imported!
106+ to_import.erase (cur_ns_it);
106107 continue ;
107108 }
108109
@@ -126,6 +127,11 @@ void Database::load(const std::string &filename,
126127 }})
127128 .first ->second ;
128129
130+ // Processing import is done and we can remove it from the list
131+ // We must already erase here because the iterator cur_ns_it might get
132+ // invalidated by an insert into to_import further below
133+ to_import.erase (cur_ns_it);
134+
129135 // enqueue all new imports of this file
130136 // and record import aliases
131137 for (auto &import : new_ns.get_ast ().get_imports ()) {
@@ -158,8 +164,6 @@ void Database::load(const std::string &filename,
158164 }
159165 }
160166 }
161-
162- to_import.erase (cur_ns_it);
163167 }
164168
165169
You can’t perform that action at this time.
0 commit comments