1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Emit warning when using "load" in declarative modules

* module/ice-9/boot-9.scm (load): Emit a warning at compile-time when
  using "load" from a declarative module.
This commit is contained in:
Andy Wingo 2019-08-28 10:28:44 +02:00
parent a2f5f9eda4
commit 607d427f81

View file

@ -3847,6 +3847,13 @@ when none is available, reading FILE-NAME with READER."
(let* ((src (syntax-source x))
(file (and src (assq-ref src 'filename)))
(dir (and (string? file) (dirname file))))
;; A module that uses `load' is not declarative.
(when (module-declarative? (current-module))
(format (current-warning-port)
"WARNING: Use of `load' in declarative module ~A. ~A\n"
(module-name (current-module))
"Add #:declarative? #f to your define-module invocation.")
(set-module-declarative?! (current-module) #f))
(syntax-case x ()
((_ arg ...)
#`(load-in-vicinity #,(or dir #'(getcwd)) arg ...))