diff --git a/main.rkt b/main.rkt index 1167f73..47f61bb 100644 --- a/main.rkt +++ b/main.rkt @@ -205,7 +205,7 @@ ellipsis-depth check-ellipsis-count] …) - (remove-duplicates acc #:key car)) + (remove-duplicates acc bound-identifier=? #:key car)) #`(let () (derive bound binders unique-at-runtime-ids ellipsis-depth) @@ -315,7 +315,8 @@ #`(begin (define-temp-ids #:concise tmp-str binder-ddd) (define temp-cached (free-id-table-ref! (multi-hash-ref! derived-valvar-cache - '(unique-at-runtime-idᵢ …) + (list unique-at-runtime-idᵢ + …) (make-free-id-table)) (quote-syntax bound) (destructure-stx-list* #'tmp-ddd @@ -324,4 +325,4 @@ (derived-valvar (quote-syntax temp-cached))) (define-syntax bound (make-syntax-mapping 'ellipsis-depth (quote-syntax temp-derived))) - (define-pvars bound)))) \ No newline at end of file + (define-pvars bound)))) \ No newline at end of file diff --git a/override.rkt b/override.rkt index f049d52..bb625d7 100644 --- a/override.rkt +++ b/override.rkt @@ -4,9 +4,15 @@ [subtemplate syntax] [quasisubtemplate quasisyntax]) stxparse-info/parse + (except-in stxparse-info/parse/experimental/template + template + quasitemplate + template/loc + quasitemplate/loc) stxparse-info/case (subtract-in racket/syntax stxparse-info/case)) (provide (all-from-out subtemplate stxparse-info/parse + stxparse-info/parse/experimental/template stxparse-info/case racket/syntax)) \ No newline at end of file diff --git a/scribblings/subtemplate.scrbl b/scribblings/subtemplate.scrbl index bc9c73b..9663f94 100644 --- a/scribblings/subtemplate.scrbl +++ b/scribblings/subtemplate.scrbl @@ -46,4 +46,10 @@ The @racketmodname[subtemplate/override] module re-provides the reader shorthands @racket[#'…] and @racket[#`…]. The @racketmodname[subtemplate/override] module also re-provides -@racketmodname[stxparse-info/parse] and @racketmodname[stxparse-info/case]. \ No newline at end of file +@racketmodname[stxparse-info/parse] and @racketmodname[stxparse-info/case]. + +The @racketmodname[subtemplate/override] module also re-provides +@racketmodname[stxparse-info/parse/experimental/template], but without +@racket[template] and @racket[quasitemplate], which are remapped to their +@racket[sub] equivalents, and without @racket[template/loc] and +@racket[quasitemplate/loc], which do not have a @racket[sub] equivalent yet. \ No newline at end of file diff --git a/test/test-subtemplate.rkt b/test/test-subtemplate.rkt index 7fc740e..ed96df6 100644 --- a/test/test-subtemplate.rkt +++ b/test/test-subtemplate.rkt @@ -56,9 +56,9 @@ '(c d)) (check-equal? (syntax->datum (syntax-parse #'(a b c d) - [(_ xⱼ zᵢ …) - (subtemplate (wᵢ …))])) - '(c/w d/w)) + [(_ xⱼ zᵢ …) + (subtemplate (wᵢ …))])) + '(c/w d/w)) (check-equal? (syntax->datum (syntax-case #'(a b c d) () [(_ xⱼ zᵢ …) @@ -66,9 +66,9 @@ '(c/w d/w)) (check-equal? (syntax->datum (syntax-parse #'(a b c d) - [(_ xⱼ zᵢ …) - (subtemplate (kⱼ wᵢ …))])) - '(b/k c/w d/w)) + [(_ xⱼ zᵢ …) + (subtemplate (kⱼ wᵢ …))])) + '(b/k c/w d/w)) (check-equal? (syntax->datum (syntax-case #'(a b c d) () [(_ xⱼ zᵢ …) @@ -76,169 +76,175 @@ '(b/k c/w d/w)) (check-equal? (syntax->datum (syntax-parse #'(a b c d) - [(_ xⱼ zᵢ …) - (subtemplate (xⱼ kⱼ (zᵢ wᵢ) …))])) - '(b b/k (c c/w) (d d/w))) + [(_ xⱼ zᵢ …) + (subtemplate (xⱼ kⱼ (zᵢ wᵢ) …))])) + '(b b/k (c c/w) (d d/w))) (check-equal? (syntax->datum (syntax-case #'(a b c d) () [(_ xⱼ zᵢ …) (subtemplate (xⱼ kⱼ (wᵢ zᵢ) …))])) '(b b/k (c/w c) (d/w d))) +;; With yᵢ appearing twice: +(check-equal? (syntax->datum (syntax-case #'(a b c) () + [(xᵢ …) + (subtemplate (yᵢ … yᵢ …))])) + '(a/y b/y c/y a/y b/y c/y)) + #;(let () - (syntax-parse #'a #;(syntax-parse #'(a b c d) - [(_ xⱼ zᵢ …) - (list (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)) - (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)))]) - [_ #;(([x1 w1] foo1 [z1 p1] [zz1 pp1]) - ([x2 w2] foo2 [z2 p2] [zz2 pp2])) - (check bound-identifier=? #'x1 #'x2)])) + (syntax-parse #'a #;(syntax-parse #'(a b c d) + [(_ xⱼ zᵢ …) + (list (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)) + (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)))]) + [_ #;(([x1 w1] foo1 [z1 p1] [zz1 pp1]) + ([x2 w2] foo2 [z2 p2] [zz2 pp2])) + (check bound-identifier=? #'x1 #'x2)])) (syntax-parse (syntax-parse #'(a b c d) - [(_ xⱼ zᵢ …) - (list (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)) - (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)))]) - [(([x1 w1] foo1 [z1 p1] [zz1 pp1]) - ([x2 w2] foo2 [z2 p2] [zz2 pp2])) - (check bound-identifier=? #'x1 #'x2) - (check bound-identifier=? #'w1 #'w2) - (check bound-identifier=? #'foo1 #'foo2) - (check bound-identifier=? #'z1 #'z2) - (check bound-identifier=? #'p1 #'p2) - (check bound-identifier=? #'zz1 #'zz2) - (check bound-identifier=? #'pp1 #'pp2) + [(_ xⱼ zᵢ …) + (list (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)) + (subtemplate ([xⱼ wⱼ] foo [zᵢ pᵢ] …)))]) + [(([x1 w1] foo1 [z1 p1] [zz1 pp1]) + ([x2 w2] foo2 [z2 p2] [zz2 pp2])) + (check bound-identifier=? #'x1 #'x2) + (check bound-identifier=? #'w1 #'w2) + (check bound-identifier=? #'foo1 #'foo2) + (check bound-identifier=? #'z1 #'z2) + (check bound-identifier=? #'p1 #'p2) + (check bound-identifier=? #'zz1 #'zz2) + (check bound-identifier=? #'pp1 #'pp2) - (check bound-identifier=? #'x1 #'b) - (check bound-identifier=? #'z1 #'c) - (check bound-identifier=? #'zz1 #'d) + (check bound-identifier=? #'x1 #'b) + (check bound-identifier=? #'z1 #'c) + (check bound-identifier=? #'zz1 #'d) - (check bound-identifier=? #'x2 #'b) - (check bound-identifier=? #'z2 #'c) - (check bound-identifier=? #'zz2 #'d) + (check bound-identifier=? #'x2 #'b) + (check bound-identifier=? #'z2 #'c) + (check bound-identifier=? #'zz2 #'d) - ;; The *1 are all different: - (check bound-identifier=? #'x1 #'x1) - (check (∘ not bound-identifier=?) #'x1 #'w1) - (check (∘ not bound-identifier=?) #'x1 #'foo1) - (check (∘ not bound-identifier=?) #'x1 #'z1) - (check (∘ not bound-identifier=?) #'x1 #'p1) - (check (∘ not bound-identifier=?) #'x1 #'zz1) - (check (∘ not bound-identifier=?) #'x1 #'pp1) + ;; The *1 are all different: + (check bound-identifier=? #'x1 #'x1) + (check (∘ not bound-identifier=?) #'x1 #'w1) + (check (∘ not bound-identifier=?) #'x1 #'foo1) + (check (∘ not bound-identifier=?) #'x1 #'z1) + (check (∘ not bound-identifier=?) #'x1 #'p1) + (check (∘ not bound-identifier=?) #'x1 #'zz1) + (check (∘ not bound-identifier=?) #'x1 #'pp1) - (check (∘ not bound-identifier=?) #'w1 #'x1) - (check bound-identifier=? #'w1 #'w1) - (check (∘ not bound-identifier=?) #'w1 #'foo1) - (check (∘ not bound-identifier=?) #'w1 #'z1) - (check (∘ not bound-identifier=?) #'w1 #'p1) - (check (∘ not bound-identifier=?) #'w1 #'zz1) - (check (∘ not bound-identifier=?) #'w1 #'pp1) + (check (∘ not bound-identifier=?) #'w1 #'x1) + (check bound-identifier=? #'w1 #'w1) + (check (∘ not bound-identifier=?) #'w1 #'foo1) + (check (∘ not bound-identifier=?) #'w1 #'z1) + (check (∘ not bound-identifier=?) #'w1 #'p1) + (check (∘ not bound-identifier=?) #'w1 #'zz1) + (check (∘ not bound-identifier=?) #'w1 #'pp1) - (check (∘ not bound-identifier=?) #'foo1 #'x1) - (check (∘ not bound-identifier=?) #'foo1 #'w1) - (check bound-identifier=? #'foo1 #'foo1) - (check (∘ not bound-identifier=?) #'foo1 #'z1) - (check (∘ not bound-identifier=?) #'foo1 #'p1) - (check (∘ not bound-identifier=?) #'foo1 #'zz1) - (check (∘ not bound-identifier=?) #'foo1 #'pp1) + (check (∘ not bound-identifier=?) #'foo1 #'x1) + (check (∘ not bound-identifier=?) #'foo1 #'w1) + (check bound-identifier=? #'foo1 #'foo1) + (check (∘ not bound-identifier=?) #'foo1 #'z1) + (check (∘ not bound-identifier=?) #'foo1 #'p1) + (check (∘ not bound-identifier=?) #'foo1 #'zz1) + (check (∘ not bound-identifier=?) #'foo1 #'pp1) - (check (∘ not bound-identifier=?) #'z1 #'x1) - (check (∘ not bound-identifier=?) #'z1 #'w1) - (check (∘ not bound-identifier=?) #'z1 #'foo1) - (check bound-identifier=? #'z1 #'z1) - (check (∘ not bound-identifier=?) #'z1 #'p1) - (check (∘ not bound-identifier=?) #'z1 #'zz1) - (check (∘ not bound-identifier=?) #'z1 #'pp1) + (check (∘ not bound-identifier=?) #'z1 #'x1) + (check (∘ not bound-identifier=?) #'z1 #'w1) + (check (∘ not bound-identifier=?) #'z1 #'foo1) + (check bound-identifier=? #'z1 #'z1) + (check (∘ not bound-identifier=?) #'z1 #'p1) + (check (∘ not bound-identifier=?) #'z1 #'zz1) + (check (∘ not bound-identifier=?) #'z1 #'pp1) - (check (∘ not bound-identifier=?) #'p1 #'x1) - (check (∘ not bound-identifier=?) #'p1 #'w1) - (check (∘ not bound-identifier=?) #'p1 #'foo1) - (check (∘ not bound-identifier=?) #'p1 #'z1) - (check bound-identifier=? #'p1 #'p1) - (check (∘ not bound-identifier=?) #'p1 #'zz1) - (check (∘ not bound-identifier=?) #'p1 #'pp1) + (check (∘ not bound-identifier=?) #'p1 #'x1) + (check (∘ not bound-identifier=?) #'p1 #'w1) + (check (∘ not bound-identifier=?) #'p1 #'foo1) + (check (∘ not bound-identifier=?) #'p1 #'z1) + (check bound-identifier=? #'p1 #'p1) + (check (∘ not bound-identifier=?) #'p1 #'zz1) + (check (∘ not bound-identifier=?) #'p1 #'pp1) - (check (∘ not bound-identifier=?) #'zz1 #'x1) - (check (∘ not bound-identifier=?) #'zz1 #'w1) - (check (∘ not bound-identifier=?) #'zz1 #'foo1) - (check (∘ not bound-identifier=?) #'zz1 #'z1) - (check (∘ not bound-identifier=?) #'zz1 #'p1) - (check bound-identifier=? #'zz1 #'zz1) - (check (∘ not bound-identifier=?) #'zz1 #'pp1) + (check (∘ not bound-identifier=?) #'zz1 #'x1) + (check (∘ not bound-identifier=?) #'zz1 #'w1) + (check (∘ not bound-identifier=?) #'zz1 #'foo1) + (check (∘ not bound-identifier=?) #'zz1 #'z1) + (check (∘ not bound-identifier=?) #'zz1 #'p1) + (check bound-identifier=? #'zz1 #'zz1) + (check (∘ not bound-identifier=?) #'zz1 #'pp1) - (check (∘ not bound-identifier=?) #'pp1 #'x1) - (check (∘ not bound-identifier=?) #'pp1 #'w1) - (check (∘ not bound-identifier=?) #'pp1 #'foo1) - (check (∘ not bound-identifier=?) #'pp1 #'z1) - (check (∘ not bound-identifier=?) #'pp1 #'p1) - (check (∘ not bound-identifier=?) #'pp1 #'zz1) - (check bound-identifier=? #'pp1 #'pp1) + (check (∘ not bound-identifier=?) #'pp1 #'x1) + (check (∘ not bound-identifier=?) #'pp1 #'w1) + (check (∘ not bound-identifier=?) #'pp1 #'foo1) + (check (∘ not bound-identifier=?) #'pp1 #'z1) + (check (∘ not bound-identifier=?) #'pp1 #'p1) + (check (∘ not bound-identifier=?) #'pp1 #'zz1) + (check bound-identifier=? #'pp1 #'pp1) - ;; The *2 are all different: - (check bound-identifier=? #'x2 #'x2) - (check (∘ not bound-identifier=?) #'x2 #'w2) - (check (∘ not bound-identifier=?) #'x2 #'foo2) - (check (∘ not bound-identifier=?) #'x2 #'z2) - (check (∘ not bound-identifier=?) #'x2 #'p2) - (check (∘ not bound-identifier=?) #'x2 #'zz2) - (check (∘ not bound-identifier=?) #'x2 #'pp2) + ;; The *2 are all different: + (check bound-identifier=? #'x2 #'x2) + (check (∘ not bound-identifier=?) #'x2 #'w2) + (check (∘ not bound-identifier=?) #'x2 #'foo2) + (check (∘ not bound-identifier=?) #'x2 #'z2) + (check (∘ not bound-identifier=?) #'x2 #'p2) + (check (∘ not bound-identifier=?) #'x2 #'zz2) + (check (∘ not bound-identifier=?) #'x2 #'pp2) - (check (∘ not bound-identifier=?) #'w2 #'x2) - (check bound-identifier=? #'w2 #'w2) - (check (∘ not bound-identifier=?) #'w2 #'foo2) - (check (∘ not bound-identifier=?) #'w2 #'z2) - (check (∘ not bound-identifier=?) #'w2 #'p2) - (check (∘ not bound-identifier=?) #'w2 #'zz2) - (check (∘ not bound-identifier=?) #'w2 #'pp2) + (check (∘ not bound-identifier=?) #'w2 #'x2) + (check bound-identifier=? #'w2 #'w2) + (check (∘ not bound-identifier=?) #'w2 #'foo2) + (check (∘ not bound-identifier=?) #'w2 #'z2) + (check (∘ not bound-identifier=?) #'w2 #'p2) + (check (∘ not bound-identifier=?) #'w2 #'zz2) + (check (∘ not bound-identifier=?) #'w2 #'pp2) - (check (∘ not bound-identifier=?) #'foo2 #'x2) - (check (∘ not bound-identifier=?) #'foo2 #'w2) - (check bound-identifier=? #'foo2 #'foo2) - (check (∘ not bound-identifier=?) #'foo2 #'z2) - (check (∘ not bound-identifier=?) #'foo2 #'p2) - (check (∘ not bound-identifier=?) #'foo2 #'zz2) - (check (∘ not bound-identifier=?) #'foo2 #'pp2) + (check (∘ not bound-identifier=?) #'foo2 #'x2) + (check (∘ not bound-identifier=?) #'foo2 #'w2) + (check bound-identifier=? #'foo2 #'foo2) + (check (∘ not bound-identifier=?) #'foo2 #'z2) + (check (∘ not bound-identifier=?) #'foo2 #'p2) + (check (∘ not bound-identifier=?) #'foo2 #'zz2) + (check (∘ not bound-identifier=?) #'foo2 #'pp2) - (check (∘ not bound-identifier=?) #'z2 #'x2) - (check (∘ not bound-identifier=?) #'z2 #'w2) - (check (∘ not bound-identifier=?) #'z2 #'foo2) - (check bound-identifier=? #'z2 #'z2) - (check (∘ not bound-identifier=?) #'z2 #'p2) - (check (∘ not bound-identifier=?) #'z2 #'zz2) - (check (∘ not bound-identifier=?) #'z2 #'pp2) + (check (∘ not bound-identifier=?) #'z2 #'x2) + (check (∘ not bound-identifier=?) #'z2 #'w2) + (check (∘ not bound-identifier=?) #'z2 #'foo2) + (check bound-identifier=? #'z2 #'z2) + (check (∘ not bound-identifier=?) #'z2 #'p2) + (check (∘ not bound-identifier=?) #'z2 #'zz2) + (check (∘ not bound-identifier=?) #'z2 #'pp2) - (check (∘ not bound-identifier=?) #'p2 #'x2) - (check (∘ not bound-identifier=?) #'p2 #'w2) - (check (∘ not bound-identifier=?) #'p2 #'foo2) - (check (∘ not bound-identifier=?) #'p2 #'z2) - (check bound-identifier=? #'p2 #'p2) - (check (∘ not bound-identifier=?) #'p2 #'zz2) - (check (∘ not bound-identifier=?) #'p2 #'pp2) + (check (∘ not bound-identifier=?) #'p2 #'x2) + (check (∘ not bound-identifier=?) #'p2 #'w2) + (check (∘ not bound-identifier=?) #'p2 #'foo2) + (check (∘ not bound-identifier=?) #'p2 #'z2) + (check bound-identifier=? #'p2 #'p2) + (check (∘ not bound-identifier=?) #'p2 #'zz2) + (check (∘ not bound-identifier=?) #'p2 #'pp2) - (check (∘ not bound-identifier=?) #'zz2 #'x2) - (check (∘ not bound-identifier=?) #'zz2 #'w2) - (check (∘ not bound-identifier=?) #'zz2 #'foo2) - (check (∘ not bound-identifier=?) #'zz2 #'z2) - (check (∘ not bound-identifier=?) #'zz2 #'p2) - (check bound-identifier=? #'zz2 #'zz2) - (check (∘ not bound-identifier=?) #'zz2 #'pp2) + (check (∘ not bound-identifier=?) #'zz2 #'x2) + (check (∘ not bound-identifier=?) #'zz2 #'w2) + (check (∘ not bound-identifier=?) #'zz2 #'foo2) + (check (∘ not bound-identifier=?) #'zz2 #'z2) + (check (∘ not bound-identifier=?) #'zz2 #'p2) + (check bound-identifier=? #'zz2 #'zz2) + (check (∘ not bound-identifier=?) #'zz2 #'pp2) - (check (∘ not bound-identifier=?) #'pp2 #'x2) - (check (∘ not bound-identifier=?) #'pp2 #'w2) - (check (∘ not bound-identifier=?) #'pp2 #'foo2) - (check (∘ not bound-identifier=?) #'pp2 #'z2) - (check (∘ not bound-identifier=?) #'pp2 #'p2) - (check (∘ not bound-identifier=?) #'pp2 #'zz2) - (check bound-identifier=? #'pp2 #'pp2)]) + (check (∘ not bound-identifier=?) #'pp2 #'x2) + (check (∘ not bound-identifier=?) #'pp2 #'w2) + (check (∘ not bound-identifier=?) #'pp2 #'foo2) + (check (∘ not bound-identifier=?) #'pp2 #'z2) + (check (∘ not bound-identifier=?) #'pp2 #'p2) + (check (∘ not bound-identifier=?) #'pp2 #'zz2) + (check bound-identifier=? #'pp2 #'pp2)]) (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (define flob (quasisubtemplate (zᵢ …))) (quasisubtemplate (yᵢ … - #,flob - zᵢ …))]) + #,flob + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) a3 b3 c3) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -250,8 +256,8 @@ (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(quasisubtemplate (zᵢ …)) - zᵢ …))]) + #,(quasisubtemplate (zᵢ …)) + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) a3 b3 c3) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -264,8 +270,8 @@ [(xᵢ …) (define flob (syntax-parse #'d [d (quasisubtemplate (zᵢ …))])) (quasisubtemplate (yᵢ … - #,flob - zᵢ …))]) + #,flob + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) a3 b3 c3) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -277,9 +283,9 @@ (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(syntax-parse #'d - [d (quasisubtemplate (zᵢ …))]) - zᵢ …))]) + #,(syntax-parse #'d + [d (quasisubtemplate (zᵢ …))]) + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) a3 b3 c3) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -291,11 +297,11 @@ (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(syntax-parse #'d - [d (quasisubtemplate (zᵢ …))]) - #,(syntax-parse #'d - [d (quasisubtemplate (zᵢ …))]) - zᵢ …))]) + #,(syntax-parse #'d + [d (quasisubtemplate (zᵢ …))]) + #,(syntax-parse #'d + [d (quasisubtemplate (zᵢ …))]) + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) (a3 b3 c3) a4 b4 c4) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -316,11 +322,11 @@ (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(syntax-parse #'d - [d (quasisubtemplate (kᵢ …))]) - #,(syntax-parse #'d - [d (quasisubtemplate (kᵢ …))]) - zᵢ …))]) + #,(syntax-parse #'d + [d (quasisubtemplate (kᵢ …))]) + #,(syntax-parse #'d + [d (quasisubtemplate (kᵢ …))]) + zᵢ …))]) [(a1 b1 c1 (a2 b2 c2) (a3 b3 c3) a4 b4 c4) (check bound-identifier=? #'a2 #'a3) (check bound-identifier=? #'b2 #'b3) @@ -351,21 +357,21 @@ (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(syntax-parse #'(d) - [(pᵢ …) (quasisubtemplate (pᵢ … zᵢ …))]) - ;; GIVES WRONG ID (re-uses the one above, shouldn't): - #,(syntax-parse #'(e) - [(pᵢ …) (quasisubtemplate (pᵢ … zᵢ …))]) - wᵢ …))])) + #,(syntax-parse #'(d) + [(pᵢ …) (quasisubtemplate (pᵢ … zᵢ …))]) + ;; GIVES WRONG ID (re-uses the one above, shouldn't): + #,(syntax-parse #'(e) + [(pᵢ …) (quasisubtemplate (pᵢ … zᵢ …))]) + wᵢ …))])) (syntax-parse (syntax-parse #'(a b c) [(xᵢ …) (quasisubtemplate (yᵢ … - #,(syntax-parse #'d - [zᵢ (quasisubtemplate (zᵢ))]) - #,(syntax-parse #'d - [zᵢ (quasisubtemplate (zᵢ))]) - zᵢ …))]) + #,(syntax-parse #'d + [zᵢ (quasisubtemplate (zᵢ))]) + #,(syntax-parse #'d + [zᵢ (quasisubtemplate (zᵢ))]) + zᵢ …))]) [(y yy yyy (d1) (d2) z zz zzz) (check bound-identifier=? #'d1 #'d2) @@ -644,3 +650,29 @@ (check bound-identifier=? #'p1 #'p2) (check bound-identifier=? #'zz1 #'zz2) (check bound-identifier=? #'pp1 #'pp2)]) + +;; Check that the derived values are NOT cached across runs of the same +;; pattern+template (GH bug #1). +(check-equal? (map (λ (v) + (syntax->datum + (syntax-parse v + [(xᵢ …) (subtemplate (yᵢ …))]))) + (list #'[] #'[a] #'[a b] #'[c d e f])) + '([] [a/y] [a/y b/y] [c/y d/y e/y f/y])) + +(check-equal? (map (λ (v) + (syntax->datum + (syntax-parse v + [(xᵢ …) (subtemplate (xᵢ … yᵢ …))]))) + (list #'[] #'[a] #'[a b] #'[c d e f])) + '([] [a a/y] [a b a/y b/y] [c d e f c/y d/y e/y f/y])) + +(check-equal? (map (λ (v) + (syntax->datum + (syntax-parse v + [(xᵢ …) (subtemplate ([xᵢ yᵢ] …))]))) + (list #'[] #'[a] #'[a b] #'[c d e f])) + '(() + ([a a/y]) + ([a a/y] [b b/y]) + ([c c/y] [d d/y] [e e/y] [f f/y]))) \ No newline at end of file