BLUELOVETH 2 anos atrás
pai
commit
66301591a2
1 arquivos alterados com 5 adições e 5 exclusões
  1. 5 5
      src/vm.h

+ 5 - 5
src/vm.h

@@ -556,11 +556,6 @@ public:
 
             Temp(VM* vm, StrName name, int type): vm(vm), name(name){
                 ImportContext* ctx = &vm->_import_context;
-                for(auto& [k,v]: ctx->pending){
-                    if(k == name){
-                        vm->_error("ImportError", fmt("circular import ", name.escape()));
-                    }
-                }
                 ctx->pending.emplace_back(name, type);
             }
 
@@ -596,6 +591,11 @@ public:
             type = 0;
             filename = fmt(name, ".py");
         }
+        for(auto& [k, v]: _import_context.pending){
+            if(k == name){
+                vm->_error("ImportError", fmt("circular import ", name.escape()));
+            }
+        }
         PyObject* ext_mod = _modules.try_get(name);
         if(ext_mod == nullptr){
             Str source;