Instrumentation at use site for provide/contract and flat contracts.
This commit is contained in:
parent
ecce6e1b85
commit
f3f5d9212a
|
@ -220,4 +220,27 @@
|
||||||
'contract-marks24
|
'contract-marks24
|
||||||
'(set-box! (contract (box/c neg-blame?) (box 1) 'pos 'neg) 2))
|
'(set-box! (contract (box/c neg-blame?) (box 1) 'pos 'neg) 2))
|
||||||
|
|
||||||
|
;; do we catch flat contracts applies with `contract-out`?
|
||||||
|
(test/spec-passed/result
|
||||||
|
'contract-marks25
|
||||||
|
'(let ()
|
||||||
|
(eval '(module prof25 racket/base
|
||||||
|
(require racket/contract 'prof-fun)
|
||||||
|
(define x 3)
|
||||||
|
(define a-contract (λ _ (named-blame? 'prof25)))
|
||||||
|
(provide
|
||||||
|
(contract-out
|
||||||
|
[x a-contract]))))
|
||||||
|
(eval '(require 'prof25))
|
||||||
|
(eval 'x))
|
||||||
|
3)
|
||||||
|
|
||||||
|
(test/spec-passed/result
|
||||||
|
'contract-marks26
|
||||||
|
'(let ()
|
||||||
|
(eval '(define/contract x (λ _ (named-blame? 'top-level)) 3))
|
||||||
|
(eval 'x))
|
||||||
|
3)
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -152,14 +152,16 @@
|
||||||
;; expressions:
|
;; expressions:
|
||||||
(quasisyntax/loc stx (#%expression #,stx)))))))
|
(quasisyntax/loc stx (#%expression #,stx)))))))
|
||||||
|
|
||||||
(struct provide/contract-transformer provide/contract-info (saved-id-table partially-applied-id)
|
(struct provide/contract-transformer provide/contract-info (saved-id-table partially-applied-id blame)
|
||||||
#:property
|
#:property
|
||||||
prop:set!-transformer
|
prop:set!-transformer
|
||||||
(λ (self stx)
|
(λ (self stx)
|
||||||
(let ([partially-applied-id (provide/contract-transformer-partially-applied-id self)]
|
(let ([partially-applied-id (provide/contract-transformer-partially-applied-id self)]
|
||||||
[saved-id-table (provide/contract-transformer-saved-id-table self)]
|
[saved-id-table (provide/contract-transformer-saved-id-table self)]
|
||||||
[rename-id (provide/contract-info-rename-id self)])
|
[rename-id (provide/contract-info-rename-id self)]
|
||||||
(with-syntax ([partially-applied-id partially-applied-id])
|
[blame (provide/contract-transformer-blame self)])
|
||||||
|
(with-syntax ([partially-applied-id partially-applied-id]
|
||||||
|
[blame blame])
|
||||||
(if (eq? 'expression (syntax-local-context))
|
(if (eq? 'expression (syntax-local-context))
|
||||||
;; In an expression context:
|
;; In an expression context:
|
||||||
(let* ([key (syntax-local-lift-context)]
|
(let* ([key (syntax-local-lift-context)]
|
||||||
|
@ -171,7 +173,9 @@
|
||||||
(syntax-local-introduce
|
(syntax-local-introduce
|
||||||
(syntax-local-lift-expression
|
(syntax-local-lift-expression
|
||||||
(add-lifted-property
|
(add-lifted-property
|
||||||
#'(partially-applied-id (quote-module-name)))))))])
|
#'(with-contract-continuation-mark
|
||||||
|
(cons blame 'no-negative-party)
|
||||||
|
(partially-applied-id (quote-module-name))))))))])
|
||||||
(when key (hash-set! saved-id-table key lifted-ctcd-val))
|
(when key (hash-set! saved-id-table key lifted-ctcd-val))
|
||||||
(define (adjust-location new-stx)
|
(define (adjust-location new-stx)
|
||||||
(datum->syntax new-stx (syntax-e new-stx) stx new-stx))
|
(datum->syntax new-stx (syntax-e new-stx) stx new-stx))
|
||||||
|
@ -195,13 +199,14 @@
|
||||||
;; expressions:
|
;; expressions:
|
||||||
(quasisyntax/loc stx (#%expression #,stx)))))))
|
(quasisyntax/loc stx (#%expression #,stx)))))))
|
||||||
|
|
||||||
(define (make-provide/contract-transformer rename-id cid id eid pos [pid #f])
|
(define (make-provide/contract-transformer rename-id cid id eid pos [pid #f] [blame #f])
|
||||||
(if pid
|
(if pid
|
||||||
(provide/contract-transformer rename-id cid id (make-hasheq) pid)
|
(provide/contract-transformer rename-id cid id (make-hasheq) pid blame)
|
||||||
(begin
|
(begin
|
||||||
;; TODO: this needs to change!
|
;; TODO: this needs to change!
|
||||||
;; syntax/parse uses this
|
;; syntax/parse uses this
|
||||||
;; this will just drop contracts for now.
|
;; this will just drop contracts for now.
|
||||||
|
;; VS: is this still the case? this function is not exported anymore
|
||||||
(λ (stx)
|
(λ (stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ args ...)
|
[(_ args ...)
|
||||||
|
@ -286,12 +291,12 @@
|
||||||
[(->i . _) (values #t (->i-valid-app-shapes ctrct))]
|
[(->i . _) (values #t (->i-valid-app-shapes ctrct))]
|
||||||
[_ (values #f #f)]))
|
[_ (values #f #f)]))
|
||||||
(with-syntax ([id id]
|
(with-syntax ([id id]
|
||||||
[(partially-applied-id extra-neg-party-argument-fn contract-id)
|
[(partially-applied-id extra-neg-party-argument-fn contract-id blame-id)
|
||||||
(generate-temporaries (list 'idX 'idY 'idZ))]
|
(generate-temporaries (list 'idX 'idY 'idZ 'idB))]
|
||||||
[ctrct ctrct])
|
[ctrct ctrct])
|
||||||
(syntax-local-lift-module-end-declaration
|
(syntax-local-lift-module-end-declaration
|
||||||
#`(begin
|
#`(begin
|
||||||
(define partially-applied-id
|
(define-values (partially-applied-id blame-id)
|
||||||
(do-partial-app contract-id
|
(do-partial-app contract-id
|
||||||
id
|
id
|
||||||
'#,name-for-blame
|
'#,name-for-blame
|
||||||
|
@ -322,7 +327,8 @@
|
||||||
(quote-syntax #,id-rename)
|
(quote-syntax #,id-rename)
|
||||||
(quote-syntax contract-id) (quote-syntax id)
|
(quote-syntax contract-id) (quote-syntax id)
|
||||||
#f #f
|
#f #f
|
||||||
(quote-syntax partially-applied-id)))))))
|
(quote-syntax partially-applied-id)
|
||||||
|
(quote-syntax blame-id)))))))
|
||||||
|
|
||||||
(define-syntax (define-module-boundary-contract stx)
|
(define-syntax (define-module-boundary-contract stx)
|
||||||
(cond
|
(cond
|
||||||
|
@ -375,7 +381,7 @@
|
||||||
'define-module-boundary-contract
|
'define-module-boundary-contract
|
||||||
pos-blame-party-expr))])]))
|
pos-blame-party-expr))])]))
|
||||||
|
|
||||||
;; ... -> (or/c #f (-> blame val))
|
;; ... -> (values (or/c #f (-> neg-party val)) blame)
|
||||||
(define (do-partial-app ctc val name pos-module-source source)
|
(define (do-partial-app ctc val name pos-module-source source)
|
||||||
(define p (parameterize ([warn-about-val-first? #f])
|
(define p (parameterize ([warn-about-val-first? #f])
|
||||||
;; when we're building the val-first projection
|
;; when we're building the val-first projection
|
||||||
|
@ -400,7 +406,7 @@
|
||||||
;; check and then toss the results.
|
;; check and then toss the results.
|
||||||
(neg-accepter 'incomplete-blame-from-provide.rkt)
|
(neg-accepter 'incomplete-blame-from-provide.rkt)
|
||||||
|
|
||||||
neg-accepter))
|
(values neg-accepter blme)))
|
||||||
|
|
||||||
(define-for-syntax (true-provide/contract provide-stx just-check-errors? who)
|
(define-for-syntax (true-provide/contract provide-stx just-check-errors? who)
|
||||||
(syntax-case provide-stx ()
|
(syntax-case provide-stx ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user