From a9792ffb18050a5ba2a1c864bc78ea997f978346 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 25 Dec 2024 10:24:10 -0500 Subject: [PATCH] Preserve ListExpression --- mathics/core/expression.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 927791f70..83e37bab4 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -1410,8 +1410,13 @@ def rules(): if not isinstance(result, EvalMixin): return result, False if result.sameQ(new): - new._timestamp_cache(evaluation) - return new, False + # Even though result and new may be the same, + # new can be a Expression[SymbolConstant: System`List...] + # while "result' might be ListExpression!? + # So make sure to use "result", not "new". + if isinstance(result, Expression): + result._timestamp_cache(evaluation) + return result, False else: return result, True