1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

analyze: 'unbound-variable' warning handles re-exported bindings.

Fixes <https://bugs.gnu.org/47031>.

* module/language/tree-il/analyze.scm (make-use-before-definition-analysis)
[resolve]: Add case for when NAME is re-exported by MOD.
* test-suite/tests/tree-il.test ("warnings")["re-exported binding"]: New test.
This commit is contained in:
Ludovic Courtès 2021-05-01 23:12:17 +02:00
parent 81094013be
commit 5969490f55
2 changed files with 18 additions and 0 deletions

View file

@ -510,6 +510,11 @@ given `tree-il' element."
;; The variable is an import. At the time of use, the
;; name is bound to the import.
'import)
((and=> (module-public-interface mod)
(lambda (interface)
(module-variable interface name)))
;; The variable is re-exported from another module.
'import)
(else
;; Variable unbound in the module.
'unbound))))))

View file

@ -578,6 +578,19 @@
#:env m
#:opts %opts-w-unbound))))))))
(pass-if "re-exported binding" ;<https://bugs.gnu.org/47031>
(null? (call-with-warnings
(lambda ()
(compile '(begin
(use-modules (srfi srfi-35))
;; This 'condition' form expands to a
;; 'make-compound-condition' call, which is
;; re-exported from (ice-9 exceptions).
(condition (&error)
(&message (message "oh!"))))
#:opts %opts-w-unbound)))))
(with-test-prefix "use-before-definition"
(define-syntax-rule (pass-if-warnings expr pat test)
(pass-if 'expr