From ae97f00ffa51c638c269e8b3e8ee3749be20fa12 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 20 Jan 2021 07:54:26 -0800 Subject: matcher: bugfix and interface change in @(require). * share/txr/stdlib/match.tl (compile-require-match): The bug here is that the condition is placed before the match.test-expr, which is incorrect. The conditions can only be evaluated if match.test-expr has succeeded, because otherwise the variables are not validated to have the correctly matching value. Also, in the documentation, the synax insinuates there can be more than one expression. So let's just make it work: require takes multiple expressions and combines them with an implicit and. * txr.1: Documentation updated. --- share/txr/stdlib/match.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index 09f1c068..0c672903 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -180,9 +180,9 @@ var-exprs (append car-match.var-exprs cdr-match.var-exprs))))) (defun compile-require-match (exp obj-var) - (mac-param-bind *match-form* (op match condition) exp + (mac-param-bind *match-form* (op match . conditions) exp (let ((match (compile-match match obj-var))) - (set match.test-expr ^(and ,condition ,match.test-expr)) + (set match.test-expr ^(and ,match.test-expr ,*conditions)) match))) (defun compile-let-match (exp obj-var) -- cgit v1.2.3