Skip to content

Delete[0] on an empty List gives: maximum recursion depth exceeded. #1105

@rocky

Description

@rocky

Description

Delete[] on an empty list of index 0 gives a maximum recursion depth error in Boxing The reason for this is that Sequence[] cannot be boxed.

How to Reproduce

In a command-line environment:

mathics -e 'Delete[{}, 0]'

or more simply:

mathics -e 'Sequence[]'

Output Given

Traceback (most recent call last):
  File "/tmp/Mathics3/mathics-core/mathics/eval/makeboxes.py", line 187, in format_element
    return format_element(element, evaluation, SymbolFullForm, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/Mathics3/mathics-core/mathics/eval/makeboxes.py", line 187, in format_element
    return format_element(element, evaluation, SymbolFullForm, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/Mathics3/mathics-core/mathics/eval/makeboxes.py", line 187, in format_element
    return format_element(element, evaluation, SymbolFullForm, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 982 more times]
  ....
  File "/tmp/Mathics3/mathics-core/mathics/core/pattern.py", line 1048, in get_pre_choices_with_order
    yield_choice(vars_dict)
  File "/tmp/Mathics3/mathics-core/mathics/core/pattern.py", line 827, in yield_choice
    if not element.does_match(
           ^^^^^^^^^^^^^^^^^^^
  File "/tmp/Mathics3/mathics-core/mathics/core/pattern.py", line 280, in does_match
    self.match(yield_match, expression, vars_dict, evaluation, fully=fully)
  File "/tmp/Mathics3/mathics-core/mathics/core/pattern.py", line 463, in match
    basic_match_expression(
  File "/tmp/Mathics3/mathics-core/mathics/core/pattern.py", line 881, in basic_match_expression
    self.head.match(yield_head, expression.get_head(), vars_dict, evaluation)
  File "/tmp/Mathics3/mathics-core/mathics/builtin/patterns.py", line 1022, in match
    self.pattern.match(yield_func, expression, new_vars, evaluation)
  File "/tmp/Mathics3/mathics-core/mathics/builtin/patterns.py", line 777, in match
    alternative.match(yield_func, expression, vars, evaluation)
RecursionError: maximum recursion depth exceeded

Expected behavior

Output:

Sequence[]

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