syntax/parse: fix ps->stx+index; fixes #1602

Collapse CDR frames separated by ORD, POST, etc. For example,
(1 ORD 2 stx) should be same as (3 stx).
This commit is contained in:
Ryan Culpepper 2017-02-01 19:05:13 -05:00 committed by Georges Dupéron
parent 6ac55c8e72
commit 2de80c8091

View File

@ -262,18 +262,19 @@ ie (ps->stx+index ps1) = (ps->stx+index ps2).
(interp parent)]
[(cons 'post parent)
(interp parent)]))
(let ([ps (ps-truncate-opaque ps)])
(let loop ([ps (ps-truncate-opaque ps)])
(match ps
[(cons (? syntax? stx) _)
(cons stx 0)]
[(cons 'car parent)
[(cons 'car _)
(cons (interp ps) 0)]
[(cons (? exact-positive-integer? n) parent)
(cons (interp parent) n)]
(match (loop parent)
[(cons stx m) (cons stx (+ m n))])]
[(cons (? ord?) parent)
(ps->stx+index parent)]
(loop parent)]
[(cons 'post parent)
(ps->stx+index parent)])))
(loop parent)])))
;; ============================================================