Skip to content

structure_cache in mathics.core.expression.structure is None but we try to set it in _is_neutral_symbol() #1405

@rocky

Description

@rocky

Description

Structure cache object is None, but we try to set it as though it were a dictionary in _is_neutral_symbol().

How to Reproduce and Output Given

$ mathics --post-mortem

In[1]:=  Needs["CodeParser`"] (* Note: You should have arranged to have CodeParser in your packages *)

ReplaceAll::reps: PacletInformation[CodeParser] is not a valid replacement rule.
ReplaceAll::reps: PacletInformation[CodeParser] is not a valid replacement rule.
ReplaceAll::reps: FileNameJoin[{Location /. PacletInformation[CodeParser], PacletInfo.wl}] is not a valid replacement rule.
CodeParser::notransport: No transport specified.

In[2]:= CodeTokenize["1"]
Traceback (most recent call last):
  File "/tmp/Mathics3/mathics-core/mathics/core/expression.py", line 1907, in _is_neutral_symbol
    definition = definitions.get_definition(symbol_name, only_if_exists=True)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/Mathics3/mathics-core/mathics/core/definitions.py", line 506, in get_definition
    raise KeyError
KeyError
...

Expected behavior

No error

Additional context

I will be putting in a PR to initialize cache to the empty dictionary instead of None, assuming that is what is intended.

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