Skip to content

Commit

Permalink
ASR: Import paths as higher priority
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaikh-Ubaid committed Apr 26, 2023
1 parent a809eee commit 8fc6a66
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3750,15 +3750,6 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
return ;
}

/*
If import_path is not empty then insert it
in the second priority. Top priority path
is runtime library path.
*/
for( auto& path: import_paths ) {
paths.push_back(path);
}

/*
Search all the paths in order and stop
when the desired module is found.
Expand Down Expand Up @@ -3820,7 +3811,13 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
if (!t) {
std::string rl_path = get_runtime_library_dir();
SymbolTable *st = current_scope;
std::vector<std::string> paths = {rl_path, parent_dir};
std::vector<std::string> paths;
for (auto &path:import_paths) {
paths.push_back(path);
}
paths.push_back(rl_path);
paths.push_back(parent_dir);

if (!main_module) {
st = st->parent;
}
Expand Down Expand Up @@ -3870,7 +3867,12 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
void visit_Import(const AST::Import_t &x) {
ASR::symbol_t *t = nullptr;
std::string rl_path = get_runtime_library_dir();
std::vector<std::string> paths = {rl_path, parent_dir};
std::vector<std::string> paths;
for (auto &path:import_paths) {
paths.push_back(path);
}
paths.push_back(rl_path);
paths.push_back(parent_dir);
SymbolTable *st = current_scope;
std::vector<std::string> mods;
for (size_t i=0; i<x.n_names; i++) {
Expand Down

0 comments on commit 8fc6a66

Please sign in to comment.