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

Skip to content

Issues with declaring and freeing out symbolic variables #2552

Closed
@anutosh491

Description

@anutosh491

This issue arises out of this PR #2528. Consider this minimalistic example

from lpython import S
from sympy import Symbol, log, E, Pow

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

def test_mrv():
    # Case 1
    x: S = Symbol("x")
    y: S = Symbol("y")
    ans1: list[S] = mmrv(y, x)
    print(ans1)
    assert len(ans1) == 0

test_mrv()
(lf) anutosh491@spbhat68:~/lpython/lpython$ lpython --enable-symengine --backend=c integration_tests/test_gruntz.py 
test_gruntz__tmp__generated__.c: In function ‘test_mrv’:
test_gruntz__tmp__generated__.c:145:12: warning: zero-length gnu_printf format string [-Wformat-zero-length]
  145 |     printf("");
      |            ^~
Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions