Wrap various syntax/parse forms in with-disappeared-uses (#1397)

fixes #1396
This commit is contained in:
Alexis King 2016-07-29 10:11:49 -07:00 committed by Ryan Culpepper
parent ba8b848f94
commit 169472487e
5 changed files with 100 additions and 93 deletions

View File

@ -30,6 +30,7 @@
(syntax-case stx ()
[(_ s x arg ...)
(parameterize ((current-syntax-context stx))
(with-disappeared-uses
(let* ([argu (parse-argu (syntax->list #'(arg ...)) #:context stx)]
[stxclass
(get-stxclass/check-arity #'s stx
@ -44,7 +45,7 @@
(app-argu parser x x (ps-empty x x) #f fh fh #f
(lambda (fh . attr-values)
(map vector '(name ...) '(depth ...) attr-values))
argu)))))]))
argu))))))]))
(define-syntaxes (syntax-class-attributes
syntax-class-arity
@ -54,7 +55,8 @@
(syntax-case stx ()
[(_ s)
(parameterize ((current-syntax-context stx))
(handler (get-stxclass #'s)))]))
(with-disappeared-uses
(handler (get-stxclass #'s))))]))
(values (mk (lambda (s)
(let ([attrs (stxclass-attrs s)])
(with-syntax ([(a ...) (map attr-name attrs)]

View File

@ -134,11 +134,12 @@
[(_ [scname c:stxclass-ctc] ...)
#:declare scname (static stxclass? "syntax class")
(parameterize ((current-syntax-context stx))
(with-disappeared-uses
#`(begin (define pos-module-source (quote-module-name))
#,@(for/list ([scname (in-list (syntax->list #'(scname ...)))]
[stxclass (in-list (attribute scname.value))]
[rec (in-list (attribute c.rec))])
(do-one-contract stx scname stxclass rec #'pos-module-source))))]))
(do-one-contract stx scname stxclass rec #'pos-module-source)))))]))
;; Copied from unstable/contract,
;; which requires racket/contract, not racket/contract/base

View File

@ -1,6 +1,7 @@
#lang racket/base
(require (for-syntax racket/base
racket/lazy-require
racket/syntax
syntax/parse/private/residual-ct) ;; keep abs.path
racket/contract/base
racket/contract/combinator
@ -22,6 +23,7 @@
(if (eq? (syntax-local-context) 'expression)
(syntax-case stx ()
[(rsc sc)
(with-disappeared-uses
(let* ([stxclass (get-stxclass #'sc)]
[splicing? (stxclass-splicing? stxclass)])
(unless (stxclass-delimit-cut? stxclass)
@ -35,7 +37,7 @@
(if splicing?
#'reified-splicing-syntax-class
#'reified-syntax-class)])
#'(ctor 'name parser 'arity '((aname adepth) ...))))])
#'(ctor 'name parser 'arity '((aname adepth) ...)))))])
#`(#%expression #,stx)))
(define (reified-syntax-class-arity r)

View File

@ -11,6 +11,7 @@
(parameterize ((current-syntax-context stx))
(syntax-case stx ()
[(dscs header sc-expr)
(with-disappeared-uses
(let-values ([(name formals arity)
(let ([p (check-stxclass-header #'header stx)])
(values (car p) (cadr p) (caddr p)))]
@ -37,4 +38,4 @@
#f))
(define-values (parser)
(lambda (x cx pr es fh0 cp0 rl success . formals)
(app-argu target-parser x cx pr es fh0 cp0 rl success argu)))))))])))
(app-argu target-parser x cx pr es fh0 cp0 rl success argu))))))))])))

View File

@ -185,6 +185,7 @@
(define-syntax (define/syntax-parse stx)
(syntax-case stx ()
[(define/syntax-parse pattern . rest)
(with-disappeared-uses
(let-values ([(rest pattern defs)
(parse-pattern+sides #'pattern
#'rest
@ -213,7 +214,7 @@
(with ([fail-handler fh0]
[cut-prompt fh0])
(parse:S x cx pattern pr es
(list (attribute name) ...))))))))))]))
(list (attribute name) ...)))))))))))]))
;; ============================================================