Skip to content

Increment and related functions hit the recursion limit when the input is undefined #1205

@aravindh-krishnamoorthy

Description

@aravindh-krishnamoorthy

Description

How to Reproduce

In[1]:= Clear[i]; Increment[i]
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[1]= $Aborted

In[2]:=  Clear[i]; PreIncrement[i]
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[2]= $Aborted

In[3]:=  Clear[i]; Decrement[i]
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[3]= $Aborted

In[4]:=  Clear[i]; PreDecrement[i]
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[4]= $Aborted

In[5]:= i
$RecursionLimit::reclim: Recursion depth of 200 exceeded.
Out[5]= $Aborted

Output Given

$RecursionLimit::reclim: Recursion depth of 200 exceeded.

Expected behavior

No recursion. An error message indicating that the input is undefined would be good.

Your Environment

Mathics 7.0.1dev0
on CPython 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:27:36) [GCC 13.3.0]
using SymPy 1.13.3, mpmath 1.3.0, numpy 2.1.3, cython Not installed

Workarounds

Workaround example for increment:

Unprotect[Increment]; Increment[i] := Undefined /; Not[ValueQ[i]]; Protect[Increment];

Priority

N/A

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions