syntax/parse: fix handling of ~seq with action patterns

This commit is contained in:
Ryan Culpepper 2019-06-20 16:20:16 +02:00
parent 2a1404f9a3
commit 685d067361
2 changed files with 15 additions and 0 deletions

View File

@ -1043,3 +1043,14 @@
(syntax-parse #'#f
[_:indirect-bad #t]
[_ #f])))))
;; from turnstile, action pattern in ~seq (6/2019)
(let ()
;; The regression required the following circumstances:
;; - the action pattern must be able to fail, so subsequent pattern gets an ORD frame
;; - the ~seq cannot be inlined away, like (a (~seq b c) d) => (a b c d), so use ~or
(convert-syntax-error
(syntax-parse #'(m 1 2 3)
[(_ (~or (~seq a b c (~parse (d e f) #'(a b c)))
(~seq x:id ...)))
(void)])))

View File

@ -1392,6 +1392,10 @@
[(pat:action ap sp) (pat:action ap (loop sp))]
[(pat:head hp tp) (pat:head hp (loop tp))]
[(pat:dots hs tp) (pat:dots hs (loop tp))]
[(pat:ord sp group index)
;; This is awkward, but it is needed to pop the ORD progress frame on success.
(define sp* (list-pattern-replace-end sp (pat:seq-end)))
(pat:head (hpat:ord (hpat:seq sp*) group index) endp)]
[(pat:pair hp tp) (pat:pair hp (loop tp))])))
;; ----------------------------------------