No current-load-relative-directory in expander
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 516
- Forks
- 103
- PR merge metrics
- No merged PRs in 30d
Description
It seems like (current-load-relative-directory) is unavailable during background expansion and no working REPL loaded, while the code runs and compiles just fine from the command line:
#lang racket
(require (for-syntax syntax/parse/pre
compiler/cm-accomplice))
(define-syntax (require/phantom stx)
(syntax-parse stx
[(_ relpath:string)
(register-external-module (path->complete-path (syntax-e #'relpath)
(current-load-relative-directory)))
#'(begin)]))
(require/phantom "test.rkt")
#|
Welcome to DrRacket, version 8.15.0.12 [cs].
Language: racket, with debugging [custom]; memory limit: 128 MB.
. . ../../racket/gitdev/racket/collects/syntax/wrap-modbeg.rkt:46:4: path->complete-path: contract violation
expected: (and/c (or/c path-string? path-for-some-system?) complete-path?)
given: #f
>
|#
Here, (current-load-relative-directory) returns #f in DrRacket but not in Racket REPL:
● [Jan10 20:47:44] $ racket
Welcome to Racket v8.15.0.12 [cs].
> (enter! "phantom-require.rkt")
"phantom-require.rkt">
During compilation, (current-load-relative-directory) also returns the load path:
● [Jan10 20:47:54] $ raco make -v phantom-require.rkt
"phantom-require.rkt":
making #<path:....../phantom-require.rkt>
[output to "compiled/phantom-require_rkt.zo"]
● [Jan10 20:48:04] $ raco make -v phantom-require.rkt
"phantom-require.rkt":
making #<path:....../test.rkt>
test.rkt:(syntax-local-phase-level 0)
making #<path:....../phantom-require.rkt>
[output to "compiled/phantom-require_rkt.zo"]
● [Jan10 20:48:06] $
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the require/phantom reproducer and the current-load-relative-directory call, then compare its value during DrRacket background expansion, in the Racket REPL, and with raco make. Done means the DrRacket case no longer produces #f for this use or otherwise avoids the reported contract violation.
Written by the indexing model from the issue text.
Assessment
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100