diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-19 07:32:44 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-19 07:32:44 -0800 |
commit | 269ec401d8d7a76f6bf497d6002eb38f168029f1 (patch) | |
tree | 432371b3d664d29d997ee4ad6279a9bbc8679343 | |
parent | d6cad17ca4111e1914f11c4c8573000e2c1dfc53 (diff) | |
download | txr-269ec401d8d7a76f6bf497d6002eb38f168029f1.tar.gz txr-269ec401d8d7a76f6bf497d6002eb38f168029f1.tar.bz2 txr-269ec401d8d7a76f6bf497d6002eb38f168029f1.zip |
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.
-rw-r--r-- | share/txr/stdlib/match.tl | 12 |
1 files 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 |