diff --git a/pkgs/racket-doc/syntax/scribblings/modcollapse.scrbl b/pkgs/racket-doc/syntax/scribblings/modcollapse.scrbl index 91bd6a1680..50f15b73fd 100644 --- a/pkgs/racket-doc/syntax/scribblings/modcollapse.scrbl +++ b/pkgs/racket-doc/syntax/scribblings/modcollapse.scrbl @@ -54,7 +54,7 @@ base. (-> module-path?))]) module-path?] [(collapse-module-path-index [module-path-index module-path-index?]) - module-path?])]{ + (or/c module-path? #f)])]{ Like @racket[collapse-module-path] when given two arguments, but the input is a @techlink[#:doc refman]{module path index}; in this case, @@ -67,7 +67,14 @@ is relative. The resulting module path is not necessarily normalized. @history[#:changed "6.1.1.8" @elem{Added the one-argument variant for collapsing a relative module path - index.}]} + index.} + #:changed "6.9.0.4" @elem{The one-argument variant may return + @racket{#false}, e.g. for an empty + module path index such as the + @racket{source-mod} and + @racket{nominal-source-mod} of an + identifier created with + @racket{syntax-local-lift-expression}.}]} @close-eval[evaluator] diff --git a/pkgs/racket-test/tests/syntax/modcollapse.rkt b/pkgs/racket-test/tests/syntax/modcollapse.rkt index 5cf7b475b5..8533da8710 100644 --- a/pkgs/racket-test/tests/syntax/modcollapse.rkt +++ b/pkgs/racket-test/tests/syntax/modcollapse.rkt @@ -1,5 +1,7 @@ #lang racket/base -(require syntax/modcollapse) +(require syntax/modcollapse + (for-syntax racket/base + syntax/modcollapse)) (define (check got expected) (unless (equal? got expected) @@ -153,3 +155,15 @@ here) (build-path here-dir "x" "apple.rkt")) + +(define-syntax (try-collapse-empty-module-path-index stx) + (datum->syntax + #f + #`'#,(collapse-module-path-index + (car + (identifier-binding + (syntax-local-lift-expression + (quote-syntax 1))))))) + +(check (try-collapse-empty-module-path-index) + #f) \ No newline at end of file diff --git a/racket/collects/syntax/modcollapse.rkt b/racket/collects/syntax/modcollapse.rkt index bfe0e80501..84613e1340 100644 --- a/racket/collects/syntax/modcollapse.rkt +++ b/racket/collects/syntax/modcollapse.rkt @@ -32,7 +32,7 @@ . -> . simple-rel-to-module-path-v/c)] [collapse-module-path-index (case-> (module-path-index? - . -> . module-path?) + . -> . (or/c module-path? #f)) ((or/c symbol? module-path-index?) rel-to-module-path-v/c . -> . simple-rel-to-module-path-v/c))])