From 269ec401d8d7a76f6bf497d6002eb38f168029f1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 19 Jan 2021 07:32:44 -0800 Subject: matcher: fix broken test case. * share/txr/stdlib/match.tl (compile-parallel-match): The problem here is that vars in the new compiled-match being returned is not a list of the same length as var-exprs (that being empty). When this is embedded in other expressions, and the vars/var-exprs are appended together, this causes a mismatch, causing assignments to go to the wrong variables. The solution is to move the binding of all-vars into a new guard. Guards are not blindly combined by appending. --- share/txr/stdlib/match.tl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 38145218..b1db1f2d 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -253,14 +253,16 @@ (mapcar (ret ^(set ,@1 nil)) (diff all-vars pm.vars))) t)))))) - (let ((guard (new match-guard - guard-expr ^(,op ,*[mapcar submatch-fun par-matches])))) + (let ((guard0 (new match-guard + guard-expr t + vars all-vars)) + (guard1 (new match-guard + guard-expr ^(,op ,*[mapcar submatch-fun par-matches])))) (new compiled-match pattern par-pat obj-var obj-var - guard-chain (list guard) - test-expr t - vars (uniq (mappend .vars par-matches)))))))) + guard-chain (list guard0 guard1) + test-expr t)))))) (defun compile-not-match (pattern obj-var) (tree-bind (op pattern) pattern -- cgit v1.2.3