diff options
author | Ludovic Courtès <ludo@gnu.org> | 2021-05-01 23:12:17 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2021-05-02 01:20:19 +0200 |
commit | 5969490f55e5a167a3eb2573a3c5241c0ce079f3 (patch) | |
tree | c42599676e193eaf5773b6418c14f41c5ad7b3b6 | |
parent | 81094013be65fe01b372af2b6eec1bc16462e99b (diff) | |
download | guile-5969490f55e5a167a3eb2573a3c5241c0ce079f3.tar.gz |
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.
-rw-r--r-- | module/language/tree-il/analyze.scm | 5 | ||||
-rw-r--r-- | test-suite/tests/tree-il.test | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm index 766568f38..1567e3ec5 100644 --- a/module/language/tree-il/analyze.scm +++ b/module/language/tree-il/analyze.scm @@ -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)))))) diff --git a/test-suite/tests/tree-il.test b/test-suite/tests/tree-il.test index 97bf17aa2..686eab9d2 100644 --- a/test-suite/tests/tree-il.test +++ b/test-suite/tests/tree-il.test @@ -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 |