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)))
|
||||
(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)
|
||||
|
|
|
@ -241,10 +241,10 @@
|
|||
;; require
|
||||
|
||||
(define-syntax (require stx)
|
||||
(unless (memq (syntax-local-context) '(module module-begin top-level))
|
||||
(raise-syntax-error #f
|
||||
"not at module level or top level"
|
||||
stx))
|
||||
(case (syntax-local-context)
|
||||
[(module-begin)
|
||||
(quasisyntax/loc stx (begin #,stx))]
|
||||
[(module top-level)
|
||||
(parameterize ([current-require-module-path #f])
|
||||
(letrec ([mode-wrap
|
||||
(lambda (mode base)
|
||||
|
@ -395,7 +395,12 @@
|
|||
(list prefetches (current-load-relative-directory))
|
||||
#f))
|
||||
(syntax/loc stx
|
||||
(begin (require in) ...)))]))))
|
||||
(begin (require in) ...)))])))]
|
||||
[else
|
||||
(raise-syntax-error #f
|
||||
"not at module level or top level"
|
||||
stx)]))
|
||||
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; require transformers
|
||||
|
@ -672,11 +677,10 @@
|
|||
;; provide
|
||||
|
||||
(define-syntax (provide stx)
|
||||
(unless (memq (syntax-local-context) '(module module-begin))
|
||||
(raise-syntax-error #f
|
||||
"not at module level"
|
||||
stx))
|
||||
|
||||
(case (syntax-local-context)
|
||||
[(module-begin)
|
||||
(quasisyntax/loc stx (begin #,stx))]
|
||||
[(module)
|
||||
(syntax-case stx ()
|
||||
[(_ out ...)
|
||||
(with-syntax ([(out ...)
|
||||
|
@ -687,7 +691,11 @@
|
|||
(#%provide #,(syntax-property
|
||||
#`(expand (provide-trampoline out ...))
|
||||
'certify-mode 'transparent)))
|
||||
'certify-mode 'transparent))]))
|
||||
'certify-mode 'transparent))])]
|
||||
[else
|
||||
(raise-syntax-error #f
|
||||
"not at module level"
|
||||
stx)]))
|
||||
|
||||
(define-syntax (provide-trampoline stx)
|
||||
(syntax-case stx ()
|
||||
|
|
Loading…
Reference in New Issue
Block a user