Skip to content
This repository was archived by the owner on Sep 13, 2019. It is now read-only.

Commit 733a6a4

Browse files
committed
expander: fix some syntax-lifting error messages
1 parent aaf5b9a commit 733a6a4

File tree

2 files changed

+2388
-2357
lines changed

2 files changed

+2388
-2357
lines changed

racket/src/expander/expand/syntax-local.rkt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@
244244
(define phase (expand-context-phase ctx))
245245
(case (core-form-sym s phase)
246246
[(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)]
248253
[else
249254
(raise-arguments-error 'syntax-local-lift-module "not a module form"
250255
"given form" s)])
@@ -253,6 +258,7 @@
253258
;; ----------------------------------------
254259

255260
(define (do-local-lift-to-module who s
261+
#:no-target-msg no-target-msg
256262
#:intro? [intro? #t]
257263
#:more-checks [more-checks void]
258264
#:get-lift-ctx get-lift-ctx
@@ -265,7 +271,8 @@
265271
(more-checks)
266272
(define ctx (get-current-expand-context who))
267273
(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))
269276
(define phase (expand-context-phase ctx)) ; we're currently at this phase
270277
(define wrt-phase (get-wrt-phase lift-ctx)) ; lift context is at this phase
271278
(define added-s (if intro? (flip-introduction-scopes s ctx) s))
@@ -280,7 +287,8 @@
280287
(define sc (new-scope 'macro))
281288
(define-values (ctx added-s)
282289
(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"
284292
#:intro? #f
285293
#:more-checks
286294
(lambda ()
@@ -306,6 +314,7 @@
306314
(define-values (ctx result-s)
307315
(do-local-lift-to-module 'syntax-local-lift-provide
308316
s
317+
#:no-target-msg "not expanding in a module run-time body"
309318
#:get-lift-ctx expand-context-to-module-lifts
310319
#:get-wrt-phase to-module-lift-context-wrt-phase
311320
#:add-lifted! add-lifted-to-module-provide!
@@ -321,6 +330,7 @@
321330
(define-values (ctx also-s)
322331
(do-local-lift-to-module 'syntax-local-lift-module-end-declaration
323332
s
333+
#:no-target-msg "not currently transforming an expression within a module declaration"
324334
#:get-lift-ctx expand-context-to-module-lifts
325335
#:get-wrt-phase (lambda (lift-ctx) 0) ; always relative to 0
326336
#:add-lifted! add-lifted-to-module-end!

0 commit comments

Comments
 (0)