* bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5
@ 2021-03-09 22:18 Ludovic Courtès
2021-05-01 20:34 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2021-03-09 22:18 UTC (permalink / raw)
To: 47031
The new ‘unbound-variable’ warning in 3.0.5 has false positives, as in
this example:
--8<---------------cut here---------------start------------->8---
$ cat /tmp/unbound.scm
(use-modules (srfi srfi-35))
(condition (&message (message "oh no!"))
(&serious))
$ guild compile -Wunbound-variable /tmp/unbound.scm
/tmp/unbound.scm:3:0: warning: possibly unbound variable `make-compound-condition'
wrote `/home/ludo/.cache/guile/ccache/3.0-LE-8-4.4/tmp/unbound.scm.go'
$ guild --version
guild (GNU Guile) 3.0.5
Copyright (C) 2021 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
--8<---------------cut here---------------end--------------->8---
3.0.4 and earlier versions are fine.
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5
2021-03-09 22:18 bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5 Ludovic Courtès
@ 2021-05-01 20:34 ` Ludovic Courtès
2021-05-01 23:26 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2021-05-01 20:34 UTC (permalink / raw)
To: 47031
[-- Attachment #1: Type: text/plain, Size: 533 bytes --]
Hello!
Ludovic Courtès <ludo@gnu.org> skribis:
> $ cat /tmp/unbound.scm
> (use-modules (srfi srfi-35))
>
> (condition (&message (message "oh no!"))
> (&serious))
> $ guild compile -Wunbound-variable /tmp/unbound.scm
> /tmp/unbound.scm:3:0: warning: possibly unbound variable `make-compound-condition'
The problem was that ‘make-compound-condition’ is re-exported from (srfi
srfi-35) and this particular case was not handled.
The attached patch fixes it. Let me know what you think!
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1714 bytes --]
diff --git a/module/language/tree-il/analyze.scm b/module/language/tree-il/analyze.scm
index 766568f38..4b53e426f 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 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 217a1000f..262c2454d 100644
--- a/test-suite/tests/tree-il.test
+++ b/test-suite/tests/tree-il.test
@@ -557,6 +557,19 @@
#:env m
#:opts %opts-w-unbound))))))))
+ (pass-if "macro-inserted binding"
+ (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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5
2021-05-01 20:34 ` Ludovic Courtès
@ 2021-05-01 23:26 ` Ludovic Courtès
0 siblings, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2021-05-01 23:26 UTC (permalink / raw)
To: 47031-done
Ludovic Courtès <ludo@gnu.org> skribis:
> The problem was that ‘make-compound-condition’ is re-exported from (srfi
> srfi-35) and this particular case was not handled.
>
> The attached patch fixes it. Let me know what you think!
Pushed as 5969490f55e5a167a3eb2573a3c5241c0ce079f3 following the
IRC’d LGTM. :-)
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-01 23:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 22:18 bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5 Ludovic Courtès
2021-05-01 20:34 ` Ludovic Courtès
2021-05-01 23:26 ` Ludovic Courtès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).