|
244 | 244 | (define phase (expand-context-phase ctx))
|
245 | 245 | (case (core-form-sym s phase)
|
246 | 246 | [(module module*)
|
247 |
| - (add-lifted-module! (expand-context-module-lifts ctx) (flip-introduction-scopes s ctx) phase)] |
| 247 | + (define lifts (expand-context-module-lifts ctx)) |
| 248 | + (unless lifts |
| 249 | + (raise-arguments-error 'syntax-local-lift-module |
| 250 | + "not currently transforming within a module declaration or top level" |
| 251 | + "form to lift" s)) |
| 252 | + (add-lifted-module! lifts (flip-introduction-scopes s ctx) phase)] |
248 | 253 | [else
|
249 | 254 | (raise-arguments-error 'syntax-local-lift-module "not a module form"
|
250 | 255 | "given form" s)])
|
|
253 | 258 | ;; ----------------------------------------
|
254 | 259 |
|
255 | 260 | (define (do-local-lift-to-module who s
|
| 261 | + #:no-target-msg no-target-msg |
256 | 262 | #:intro? [intro? #t]
|
257 | 263 | #:more-checks [more-checks void]
|
258 | 264 | #:get-lift-ctx get-lift-ctx
|
|
265 | 271 | (more-checks)
|
266 | 272 | (define ctx (get-current-expand-context who))
|
267 | 273 | (define lift-ctx (get-lift-ctx ctx))
|
268 |
| - (unless lift-ctx (raise-arguments-error who "no lift target")) |
| 274 | + (unless lift-ctx (raise-arguments-error who no-target-msg |
| 275 | + "form to lift" s)) |
269 | 276 | (define phase (expand-context-phase ctx)) ; we're currently at this phase
|
270 | 277 | (define wrt-phase (get-wrt-phase lift-ctx)) ; lift context is at this phase
|
271 | 278 | (define added-s (if intro? (flip-introduction-scopes s ctx) s))
|
|
280 | 287 | (define sc (new-scope 'macro))
|
281 | 288 | (define-values (ctx added-s)
|
282 | 289 | (do-local-lift-to-module 'syntax-local-lift-require
|
283 |
| - (datum->syntax #f s) |
| 290 | + (datum->syntax #f s) |
| 291 | + #:no-target-msg "could not find target context" |
284 | 292 | #:intro? #f
|
285 | 293 | #:more-checks
|
286 | 294 | (lambda ()
|
|
306 | 314 | (define-values (ctx result-s)
|
307 | 315 | (do-local-lift-to-module 'syntax-local-lift-provide
|
308 | 316 | s
|
| 317 | + #:no-target-msg "not expanding in a module run-time body" |
309 | 318 | #:get-lift-ctx expand-context-to-module-lifts
|
310 | 319 | #:get-wrt-phase to-module-lift-context-wrt-phase
|
311 | 320 | #:add-lifted! add-lifted-to-module-provide!
|
|
321 | 330 | (define-values (ctx also-s)
|
322 | 331 | (do-local-lift-to-module 'syntax-local-lift-module-end-declaration
|
323 | 332 | s
|
| 333 | + #:no-target-msg "not currently transforming an expression within a module declaration" |
324 | 334 | #:get-lift-ctx expand-context-to-module-lifts
|
325 | 335 | #:get-wrt-phase (lambda (lift-ctx) 0) ; always relative to 0
|
326 | 336 | #:add-lifted! add-lifted-to-module-end!
|
|
0 commit comments