Skip to content

Commit 4150db6

Browse files
authored
Merge pull request #2437 from anutosh491/gruntz_01
Adding initial test for gruntz
2 parents 5943ff7 + b122222 commit 4150db6

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

integration_tests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ RUN(NAME symbolics_10 LABELS cpython_sym c_sym llvm_sym NOFAST)
717717
RUN(NAME symbolics_11 LABELS cpython_sym c_sym llvm_sym NOFAST)
718718
RUN(NAME symbolics_12 LABELS cpython_sym c_sym llvm_sym NOFAST)
719719
RUN(NAME symbolics_13 LABELS cpython_sym c_sym llvm_sym NOFAST)
720+
RUN(NAME test_gruntz LABELS cpython_sym llvm_sym NOFAST)
720721

721722
RUN(NAME sizeof_01 LABELS llvm c
722723
EXTRAFILES sizeof_01b.c)
@@ -775,7 +776,7 @@ RUN(NAME func_dep_03 LABELS cpython llvm c)
775776
RUN(NAME func_dep_04 LABELS cpython llvm c)
776777
RUN(NAME func_internal_def_01 LABELS cpython llvm NOFAST)
777778
RUN(NAME func_01 LABELS cpython llvm)
778-
RUN(NAME func_02 LABELS c_sym)
779+
RUN(NAME func_02 LABELS c_sym llvm_sym NOFAST)
779780

780781
RUN(NAME float_01 LABELS cpython llvm c wasm wasm_x64)
781782
RUN(NAME recursive_01 LABELS cpython llvm c wasm wasm_x64 wasm_x86)

integration_tests/func_02.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from lpython import S
1+
from lpython import S, Out
22
from sympy import pi
33

44
def func(r: Out[S]) -> None:

integration_tests/test_gruntz.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from lpython import S
2+
from sympy import Symbol
3+
4+
def mmrv(e: S, x: S) -> list[S]:
5+
l: list[S] = []
6+
if not e.has(x):
7+
return l
8+
else:
9+
raise
10+
11+
def test_mrv1():
12+
x: S = Symbol("x")
13+
y: S = Symbol("y")
14+
ans: list[S] = mmrv(y, x)
15+
assert len(ans) == 0
16+
17+
test_mrv1()

src/libasr/pass/pass_utils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ namespace LCompilers {
120120
ASR::is_a<ASR::SymbolicExpression_t>(*ASRUtils::expr_type(var)));
121121
}
122122

123+
static inline bool is_symbolic_list_type(ASR::expr_t* var) {
124+
if (ASR::is_a<ASR::List_t>(*ASRUtils::expr_type(var))) {
125+
ASR::List_t *list = ASR::down_cast<ASR::List_t>(ASRUtils::expr_type(var));
126+
return (list->m_type->type == ASR::ttypeType::SymbolicExpression);
127+
}
128+
return false;
129+
}
130+
123131
template <class Struct>
124132
class PassVisitor: public ASR::ASRPassBaseWalkVisitor<Struct> {
125133

@@ -788,7 +796,7 @@ namespace LCompilers {
788796
* in avoiding deep copies and the destination memory directly gets
789797
* filled inside the function.
790798
*/
791-
if( is_array_or_struct_or_symbolic(x->m_return_var)) {
799+
if( is_array_or_struct_or_symbolic(x->m_return_var) || is_symbolic_list_type(x->m_return_var)) {
792800
for( auto& s_item: x->m_symtab->get_scope() ) {
793801
ASR::symbol_t* curr_sym = s_item.second;
794802
if( curr_sym->type == ASR::symbolType::Variable ) {

0 commit comments

Comments
 (0)