syntax/parse: add dynamic check for null ellipsis-head match
Otherwise, nullable ellipsis-head patterns could cause infinite loop.
This commit is contained in:
parent
669460da34
commit
fb5c1310d8
|
@ -984,8 +984,9 @@ Conventions:
|
||||||
(for/list ([id (in-list ids)]) (bound-id-table-ref table id)))])
|
(for/list ([id (in-list ids)]) (bound-id-table-ref table id)))])
|
||||||
(with-syntax ([(id ...) ids]
|
(with-syntax ([(id ...) ids]
|
||||||
[(alt-id ...) alt-ids])
|
[(alt-id ...) alt-ids])
|
||||||
#`(let ([alt-id (rep:combine repc (attribute id) alt-id)] ...)
|
#`(let ([alt-id (rep:combine repc (attribute id) alt-id)] ...
|
||||||
k))))
|
[diff (ps-difference pr pr*)])
|
||||||
|
(if (zero? diff) (error/null-eh-match) k)))))
|
||||||
(syntax-case #'repc ()
|
(syntax-case #'repc ()
|
||||||
[#f #`(parse:H x cx x* cx* pr* head pr es k*)]
|
[#f #`(parse:H x cx x* cx* pr* head pr es k*)]
|
||||||
[_ #`(parse:H x cx x* cx* pr* head pr es
|
[_ #`(parse:H x cx x* cx* pr* head pr es
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
datum->syntax/with-clause
|
datum->syntax/with-clause
|
||||||
check/force-syntax-list^depth
|
check/force-syntax-list^depth
|
||||||
check-literal*
|
check-literal*
|
||||||
|
error/null-eh-match
|
||||||
begin-for-syntax/once
|
begin-for-syntax/once
|
||||||
|
|
||||||
name->too-few/once
|
name->too-few/once
|
||||||
|
@ -216,6 +217,10 @@
|
||||||
(and used-phase (- used-phase mod-phase)))
|
(and used-phase (- used-phase mod-phase)))
|
||||||
ctx id)))
|
ctx id)))
|
||||||
|
|
||||||
|
;; error/null-eh-match : -> (escapes)
|
||||||
|
(define (error/null-eh-match)
|
||||||
|
(error 'syntax-parse "an ellipsis-head pattern matched an empty sequence"))
|
||||||
|
|
||||||
;; (begin-for-syntax/once expr/phase1 ...)
|
;; (begin-for-syntax/once expr/phase1 ...)
|
||||||
;; evaluates in pass 2 of module/intdefs expansion
|
;; evaluates in pass 2 of module/intdefs expansion
|
||||||
(define-syntax (begin-for-syntax/once stx)
|
(define-syntax (begin-for-syntax/once stx)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user