From e1dee54db77c38e3e8fdb7c42297985c4636d815 Mon Sep 17 00:00:00 2001 From: Aravindh Krishnamoorthy Date: Tue, 19 Nov 2024 22:27:02 +0100 Subject: [PATCH] Fix optional patterns without default values: Newpattern only if not set. --- mathics/core/pattern.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mathics/core/pattern.py b/mathics/core/pattern.py index 6147f686d..acf34f646 100644 --- a/mathics/core/pattern.py +++ b/mathics/core/pattern.py @@ -724,9 +724,10 @@ def match_expression_with_one_identity( result = defaultvalue_expr.evaluate(evaluation) assert result is not None if result.sameQ(defaultvalue_expr): - # The optional pattern has no default value - # for the given position - new_pattern = pat_elem + if new_pattern is None: + # The optional pattern has no default value + # for the given position + new_pattern = pat_elem else: optionals[key] = result else: