defer require
and provide
expansion to module body
Closes PR 14936
This commit is contained in:
parent
c6802ed107
commit
2d4b4527c0
|
@ -1294,6 +1294,12 @@
|
||||||
(dynamic-require tmx 'x)))
|
(dynamic-require tmx 'x)))
|
||||||
(delete-file zo-path))
|
(delete-file zo-path))
|
||||||
|
|
||||||
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Check that `provide` doesn't run enclosed expanders until within a
|
||||||
|
;; module (as opposed to a `#%module-begin` expansion):
|
||||||
|
|
||||||
|
(module check-contract-out-by-itself racket (provide (contract-out)))
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(report-errs)
|
(report-errs)
|
||||||
|
|
|
@ -241,10 +241,10 @@
|
||||||
;; require
|
;; require
|
||||||
|
|
||||||
(define-syntax (require stx)
|
(define-syntax (require stx)
|
||||||
(unless (memq (syntax-local-context) '(module module-begin top-level))
|
(case (syntax-local-context)
|
||||||
(raise-syntax-error #f
|
[(module-begin)
|
||||||
"not at module level or top level"
|
(quasisyntax/loc stx (begin #,stx))]
|
||||||
stx))
|
[(module top-level)
|
||||||
(parameterize ([current-require-module-path #f])
|
(parameterize ([current-require-module-path #f])
|
||||||
(letrec ([mode-wrap
|
(letrec ([mode-wrap
|
||||||
(lambda (mode base)
|
(lambda (mode base)
|
||||||
|
@ -395,7 +395,12 @@
|
||||||
(list prefetches (current-load-relative-directory))
|
(list prefetches (current-load-relative-directory))
|
||||||
#f))
|
#f))
|
||||||
(syntax/loc stx
|
(syntax/loc stx
|
||||||
(begin (require in) ...)))]))))
|
(begin (require in) ...)))])))]
|
||||||
|
[else
|
||||||
|
(raise-syntax-error #f
|
||||||
|
"not at module level or top level"
|
||||||
|
stx)]))
|
||||||
|
|
||||||
|
|
||||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; require transformers
|
;; require transformers
|
||||||
|
@ -672,11 +677,10 @@
|
||||||
;; provide
|
;; provide
|
||||||
|
|
||||||
(define-syntax (provide stx)
|
(define-syntax (provide stx)
|
||||||
(unless (memq (syntax-local-context) '(module module-begin))
|
(case (syntax-local-context)
|
||||||
(raise-syntax-error #f
|
[(module-begin)
|
||||||
"not at module level"
|
(quasisyntax/loc stx (begin #,stx))]
|
||||||
stx))
|
[(module)
|
||||||
|
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(_ out ...)
|
[(_ out ...)
|
||||||
(with-syntax ([(out ...)
|
(with-syntax ([(out ...)
|
||||||
|
@ -687,7 +691,11 @@
|
||||||
(#%provide #,(syntax-property
|
(#%provide #,(syntax-property
|
||||||
#`(expand (provide-trampoline out ...))
|
#`(expand (provide-trampoline out ...))
|
||||||
'certify-mode 'transparent)))
|
'certify-mode 'transparent)))
|
||||||
'certify-mode 'transparent))]))
|
'certify-mode 'transparent))])]
|
||||||
|
[else
|
||||||
|
(raise-syntax-error #f
|
||||||
|
"not at module level"
|
||||||
|
stx)]))
|
||||||
|
|
||||||
(define-syntax (provide-trampoline stx)
|
(define-syntax (provide-trampoline stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user