redex: don't treat _ as a binder in extract-names

Closes PR 14466
This commit is contained in:
Burke Fetscher 2014-04-25 14:52:28 -05:00
parent 09d294abe1
commit d1ba8c95d7
2 changed files with 21 additions and 5 deletions

View File

@ -536,9 +536,10 @@
(syntax (rest dots)))])))
(define (binds? nts bind-names? x)
(or (and bind-names? (memq (syntax-e x) nts))
(and bind-names? (memq (syntax-e x) underscore-allowed))
(regexp-match #rx"_" (symbol->string (syntax-e x)))))
(and (not (eq? '_ (syntax-e x)))
(or (and bind-names? (memq (syntax-e x) nts))
(and bind-names? (memq (syntax-e x) underscore-allowed))
(regexp-match #rx"_" (symbol->string (syntax-e x))))))
(define (binds-in-right-hand-side? nts bind-names? x)
(and (binds? nts bind-names? x)

View File

@ -569,8 +569,23 @@
(add-minuses 11 count)))))
'()))
(test (< cpu 1000) #t))
(let ()
;; _ as a non-binding match
(define-language L)
(test (pair? (redex-match L _ '(1 2 3)))
#t)
(test (redex-match L (_ _) '(1 2 3))
#f)
(test (pair? (redex-match L (_ _ ...)'(1 2)))
#t)
(test (redex-match L (_ _ ...)'())
#f)
(test (pair? (redex-match L (_ (_ _ ...) ...) '((1 2) (3 4) (5 6))))
'#t)
(test (redex-match L (_ (_ _ ...) ...) '((1 2) (3 4) () (5 6)))
#f))
;