Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixed visit_if for SymbolicCompare cases #2535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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