diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index e4b0321dc6..5801f37afa 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -499,6 +499,8 @@ RUN(NAME vec_01 LABELS cpython llvm c) RUN(NAME test_str_comparison LABELS cpython llvm c) RUN(NAME test_bit_length LABELS cpython llvm c) RUN(NAME str_to_list_cast LABELS cpython llvm c) +RUN(NAME test_sys_01 LABELS cpython llvm c) + RUN(NAME test_package_01 LABELS cpython llvm) RUN(NAME test_pkg_lpdraw LABELS cpython llvm wasm) diff --git a/integration_tests/test_sys_01.py b/integration_tests/test_sys_01.py new file mode 100644 index 0000000000..e15e0b4503 --- /dev/null +++ b/integration_tests/test_sys_01.py @@ -0,0 +1,2 @@ +import sys +sys.exit(0) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 1d491286e9..58c33df44f 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -5900,6 +5900,24 @@ class BodyVisitor : public CommonVisitor { throw SemanticError("'" + value + "' is not defined in the scope", x.base.base.loc); } + if (ASR::is_a(*t)) { + std::string call_name = at->m_attr; + std::string call_name_store = "__" + value + "_" + call_name; + ASR::Module_t *m = ASR::down_cast(t); + call_name_store = ASRUtils::get_mangled_name(m, call_name_store); + ASR::symbol_t *st = current_scope->resolve_symbol(call_name_store); + if (!st) { + st = import_from_module(al, m, current_scope, value, + call_name, call_name_store, x.base.base.loc); + current_scope->add_symbol(call_name_store, st); + } + Vec args; + args.reserve(al, c->n_args); + visit_expr_list(c->m_args, c->n_args, args); + tmp = make_call_helper(al, st, current_scope, args, + call_name, x.base.base.loc); + return; + } Vec elements; elements.reserve(al, c->n_args); for (size_t i = 0; i < c->n_args; ++i) {