From db186784e3f47e713c7bf87ea331c2a17e7cb5ed Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 2 Jul 2017 22:10:03 +0900 Subject: [PATCH] don't include underscore in ellipsis pattern vars (issue #421) --- lib/init-7.scm | 3 ++- tests/r7rs-tests.scm | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/init-7.scm b/lib/init-7.scm index 01031784..76d1cb90 100644 --- a/lib/init-7.scm +++ b/lib/init-7.scm @@ -829,7 +829,8 @@ (define (all-vars x dim) (let lp ((x x) (dim dim) (vars '())) (cond ((identifier? x) - (if (any (lambda (lit) (compare x lit)) lits) + (if (or (any (lambda (lit) (compare x lit)) lits) + (compare x _underscore)) vars (cons (cons x dim) vars))) ((ellipsis? x) (lp (car x) (+ dim 1) (lp (cddr x) dim vars))) diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm index 20f8a512..fa5fe36b 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -473,6 +473,12 @@ ((foo _) '_))) (test '_ (underscore foo)) +(let () + (define-syntax underscore2 + (syntax-rules () + ((underscore2 (a _) ...) 42))) + (test 42 (underscore2 (1 2)))) + (define-syntax count-to-2 (syntax-rules () ((_) 0)