Skip to content

Commit

Permalink
Merge pull request #2535 from anutosh491/if_1
Browse files Browse the repository at this point in the history
Fixed visit_if for SymbolicCompare cases
  • Loading branch information
certik authored Feb 15, 2024
2 parents 4f37bb2 + 16a4ed8 commit 6098157
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ RUN(NAME symbolics_14 LABELS cpython_sym c_sym llvm_sym NOFAST)
RUN(NAME test_gruntz LABELS cpython_sym c_sym llvm_sym NOFAST)
RUN(NAME symbolics_15 LABELS c_sym llvm_sym NOFAST)
RUN(NAME symbolics_16 LABELS cpython_sym c_sym llvm_sym NOFAST)
RUN(NAME symbolics_17 LABELS cpython_sym c_sym llvm_sym NOFAST)

RUN(NAME sizeof_01 LABELS llvm c
EXTRAFILES sizeof_01b.c)
Expand Down
10 changes: 10 additions & 0 deletions integration_tests/symbolics_17.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from lpython import S
from sympy import Symbol, pi

def test_main():
x: S = Symbol('x')
if x != pi:
print(x != pi)
assert x != pi

test_main()
4 changes: 3 additions & 1 deletion src/libasr/pass/replace_symbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,9 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor<ReplaceSymbolicVisi
} else {
function_call = basic_compare(xx.base.base.loc, "basic_neq", s->m_left, s->m_right);
}
xx.m_test = function_call;
ASR::stmt_t* stmt = ASRUtils::STMT(ASR::make_If_t(al, xx.base.base.loc, function_call,
xx.m_body, xx.n_body, xx.m_orelse, xx.n_orelse));
pass_result.push_back(al, stmt);
}
}

Expand Down

0 comments on commit 6098157

Please sign in to comment.