Skip to content

Commit

Permalink
Merge pull request #957 from Mathics3/fix_956
Browse files Browse the repository at this point in the history
fix #956
  • Loading branch information
rocky authored Jan 9, 2024
2 parents bfaf356 + 826bedb commit 4589e04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mathics/builtin/procedural.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def eval(self, expr, rules, evaluation):
evaluation.message("Switch", "argct", "Switch", len(rules) + 1)
return
for pattern, value in zip(rules[::2], rules[1::2]):
if match(expr, pattern, evaluation):
if match(expr, pattern.evaluate(evaluation), evaluation):
return value.evaluate(evaluation)
# return unevaluated Switch when no pattern matches

Expand Down
6 changes: 6 additions & 0 deletions test/builtin/test_procedural.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def test_nestwhile(str_expr, str_expected):
("res", None, "Null", None),
("res=CompoundExpression[]", None, "Null", None),
("res", None, "Null", None),
(
"{MatchQ[Infinity,Infinity],Switch[Infinity,Infinity,True,_,False]}",
None,
"{True, True}",
"Issue #956",
),
(
"Clear[f];Clear[g];Clear[h];Clear[i];Clear[n];Clear[res];Clear[z]; ",
None,
Expand Down

0 comments on commit 4589e04

Please sign in to comment.