Skip to content

Commit

Permalink
Merge pull request #2437 from anutosh491/gruntz_01
Browse files Browse the repository at this point in the history
Adding initial test for gruntz
  • Loading branch information
certik authored Dec 4, 2023
2 parents 5943ff7 + b122222 commit 4150db6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/func_02.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from lpython import S
from lpython import S, Out
from sympy import pi

def func(r: Out[S]) -> None:
Expand Down
17 changes: 17 additions & 0 deletions integration_tests/test_gruntz.py
Original file line number Diff line number Diff line change
@@ -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()
10 changes: 9 additions & 1 deletion src/libasr/pass/pass_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ namespace LCompilers {
ASR::is_a<ASR::SymbolicExpression_t>(*ASRUtils::expr_type(var)));
}

static inline bool is_symbolic_list_type(ASR::expr_t* var) {
if (ASR::is_a<ASR::List_t>(*ASRUtils::expr_type(var))) {
ASR::List_t *list = ASR::down_cast<ASR::List_t>(ASRUtils::expr_type(var));
return (list->m_type->type == ASR::ttypeType::SymbolicExpression);
}
return false;
}

template <class Struct>
class PassVisitor: public ASR::ASRPassBaseWalkVisitor<Struct> {

Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 4150db6

Please sign in to comment.