diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index cf1ce217c9..d5a477f006 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -717,6 +717,7 @@ RUN(NAME symbolics_10 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_11 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_12 LABELS cpython_sym c_sym llvm_sym NOFAST) RUN(NAME symbolics_13 LABELS cpython_sym c_sym llvm_sym NOFAST) +RUN(NAME test_gruntz LABELS cpython_sym llvm_sym NOFAST) RUN(NAME sizeof_01 LABELS llvm c EXTRAFILES sizeof_01b.c) @@ -775,7 +776,7 @@ RUN(NAME func_dep_03 LABELS cpython llvm c) RUN(NAME func_dep_04 LABELS cpython llvm c) RUN(NAME func_internal_def_01 LABELS cpython llvm NOFAST) RUN(NAME func_01 LABELS cpython llvm) -RUN(NAME func_02 LABELS c_sym) +RUN(NAME func_02 LABELS c_sym llvm_sym NOFAST) RUN(NAME float_01 LABELS cpython llvm c wasm wasm_x64) RUN(NAME recursive_01 LABELS cpython llvm c wasm wasm_x64 wasm_x86) diff --git a/integration_tests/func_02.py b/integration_tests/func_02.py index 73c1f8e8f0..ea4fdf5b2b 100644 --- a/integration_tests/func_02.py +++ b/integration_tests/func_02.py @@ -1,4 +1,4 @@ -from lpython import S +from lpython import S, Out from sympy import pi def func(r: Out[S]) -> None: diff --git a/integration_tests/test_gruntz.py b/integration_tests/test_gruntz.py new file mode 100644 index 0000000000..6c7ddcb7b8 --- /dev/null +++ b/integration_tests/test_gruntz.py @@ -0,0 +1,17 @@ +from lpython import S +from sympy import Symbol + +def mmrv(e: S, x: S) -> list[S]: + l: list[S] = [] + if not e.has(x): + return l + else: + raise + +def test_mrv1(): + x: S = Symbol("x") + y: S = Symbol("y") + ans: list[S] = mmrv(y, x) + assert len(ans) == 0 + +test_mrv1() \ No newline at end of file diff --git a/src/libasr/pass/pass_utils.h b/src/libasr/pass/pass_utils.h index 27b5ee5bb8..884195de25 100644 --- a/src/libasr/pass/pass_utils.h +++ b/src/libasr/pass/pass_utils.h @@ -120,6 +120,14 @@ namespace LCompilers { ASR::is_a(*ASRUtils::expr_type(var))); } + static inline bool is_symbolic_list_type(ASR::expr_t* var) { + if (ASR::is_a(*ASRUtils::expr_type(var))) { + ASR::List_t *list = ASR::down_cast(ASRUtils::expr_type(var)); + return (list->m_type->type == ASR::ttypeType::SymbolicExpression); + } + return false; + } + template class PassVisitor: public ASR::ASRPassBaseWalkVisitor { @@ -788,7 +796,7 @@ namespace LCompilers { * in avoiding deep copies and the destination memory directly gets * filled inside the function. */ - if( is_array_or_struct_or_symbolic(x->m_return_var)) { + if( is_array_or_struct_or_symbolic(x->m_return_var) || is_symbolic_list_type(x->m_return_var)) { for( auto& s_item: x->m_symtab->get_scope() ) { ASR::symbol_t* curr_sym = s_item.second; if( curr_sym->type == ASR::symbolType::Variable ) {