Skip to content

Commit 2d8145c

Browse files
committed
Ensure the main is not present for --disable-main
This fixes a regression introduced by lcompilers#1732.
1 parent eb7b62e commit 2d8145c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6731,6 +6731,16 @@ Result<ASR::TranslationUnit_t*> python_ast_to_asr(Allocator &al, LocationManager
67316731
throw LCompilersException("Verify failed");
67326732
};
67336733
#endif
6734+
if (compiler_options.disable_main) {
6735+
// TODO: the main program should have not been created, but sometimes
6736+
// it is, so we explicitly remove it here.
6737+
for (auto &item : tu->m_global_scope->get_scope()) {
6738+
if (ASR::is_a<ASR::Program_t>(*item.second)) {
6739+
tu->m_global_scope->erase_symbol(item.first);
6740+
break;
6741+
}
6742+
}
6743+
}
67346744
}
67356745

67366746
return tu;

0 commit comments

Comments
 (0)