lcompilers / lpython

Python compiler
https://lpython.org/
Other
1.5k stars 158 forks source link

Fixing issues with freeing variables #2569

Closed anutosh491 closed 7 months ago

anutosh491 commented 7 months ago

Fixes #2533 Fixes #2552

This Pr fixes all faulty cases mentioned in the above issues.

anutosh491 commented 7 months ago

I think this is ready. Have added relevant failing cases from the above issues for the same.

anutosh491 commented 7 months ago

Actually no, I came across a case which is not working yet

def mmrv(e: S, x: S) -> list[S]:
    empty_list : list[S] = []
    if e.func == Pow:
        if e.args[0] != E:
            return empty_list
        else:
            arg1: S = e.args[1]
            print(arg1)
            if arg1.func == log:
                return empty_list
    else:
        raise

def test_mrv():
    # Case 1
    x: S = Symbol("x")
    ans5: list[S] = mmrv(exp(log(x)), x)
    assert len(ans5) == 0

test_mrv()
(lf) anutosh491@spbhat68:~/lpython/lpython$ lpython --enable-symengine integration_tests/test_gruntz.py --backend=c
0x7ffeedf6e158

Debugging this now.

Update : Commit 3 fixes it