GNU bug report logs - #47031
False positives for ‘-Wunbound-variable’ in 3.0.5

Previous Next

Package: guile;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Tue, 9 Mar 2021 22:19:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 47031 in the body.
You can then email your comments to 47031 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#47031; Package guile. (Tue, 09 Mar 2021 22:19:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Tue, 09 Mar 2021 22:19:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: False positives for ‘-Wunbound-variable’ in 3.0.5
Date: Tue, 09 Mar 2021 23:18:19 +0100
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’.




Information forwarded to bug-guile <at> gnu.org:
bug#47031; Package guile. (Sat, 01 May 2021 20:35:02 GMT) Full text and rfc822 format available.

Message #8 received at 47031 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 47031 <at> debbugs.gnu.org
Subject: Re: bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5
Date: Sat, 01 May 2021 22:34:32 +0200
[Message part 1 (text/plain, inline)]
Hello!

Ludovic Courtès <ludo <at> 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’.

[Message part 2 (text/x-patch, inline)]
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

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 01 May 2021 23:27:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Sat, 01 May 2021 23:27:02 GMT) Full text and rfc822 format available.

Message #13 received at 47031-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 47031-done <at> debbugs.gnu.org
Subject: Re: bug#47031: False positives for ‘-Wunbound-variable’ in 3.0.5
Date: Sun, 02 May 2021 01:26:43 +0200
Ludovic Courtès <ludo <at> 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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 30 May 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 324 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.