@@ -144,17 +144,20 @@ namespace Ark::internal
144144 // if we had specific symbols to import, check that those exist
145145 if (!namespace_.symbols .empty ())
146146 {
147- for (const auto & sym : namespace_.symbols )
148- {
149- if (!scope->get (sym, true ).has_value ())
150- throw CodeError (
151- fmt::format (" ImportError: Can not import symbol {} from {}, as it isn't in the package" , sym, namespace_.name ),
152- CodeErrorContext (
153- namespace_.ast ->filename (),
154- namespace_.ast ->line (),
155- namespace_.ast ->col (),
156- " import" ));
157- }
147+ const auto it = std::ranges::find_if (
148+ namespace_.symbols ,
149+ [&scope](const std::string& sym) -> bool {
150+ return !scope->get (sym, true ).has_value ();
151+ });
152+
153+ if (it != namespace_.symbols .end ())
154+ throw CodeError (
155+ fmt::format (" ImportError: Can not import symbol {} from {}, as it isn't in the package" , *it, namespace_.name ),
156+ CodeErrorContext (
157+ namespace_.ast ->filename (),
158+ namespace_.ast ->line (),
159+ namespace_.ast ->col (),
160+ " import" ));
158161 }
159162
160163 m_scope_resolver.saveNamespaceAndRemove ();
@@ -266,7 +269,7 @@ namespace Ark::internal
266269 // update the declared variable name to use the fully qualified name
267270 // this will prevent name conflicts, and handle scope resolution
268271 std::string old_name = child.string ();
269- std::string fqn = updateSymbolWithFullyQualifiedName (child);
272+ updateSymbolWithFullyQualifiedName (child);
270273 // FIXME: addDefinedSymbol(fqn, true); ?
271274 addDefinedSymbol (old_name, true );
272275 }
0 commit comments