GNU bug report logs - #23821
Misleading error for optargs

Previous Next

Package: guile;

Reported by: Mike Gran <spk121 <at> yahoo.com>

Date: Wed, 22 Jun 2016 05:05:01 UTC

Severity: normal

Done: Andy Wingo <wingo <at> pobox.com>

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 23821 in the body.
You can then email your comments to 23821 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#23821; Package guile. (Wed, 22 Jun 2016 05:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Gran <spk121 <at> yahoo.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Wed, 22 Jun 2016 05:05:02 GMT) Full text and rfc822 format available.

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

From: Mike Gran <spk121 <at> yahoo.com>
To: Bug Guile <bug-guile <at> gnu.org>
Subject: Misleading error for optargs
Date: Wed, 22 Jun 2016 05:03:59 +0000 (UTC)
The following program returns a confusing error with guile 2.0.11

  (use-modules (ice-9 optargs)) 
  (define* (func A #:key B) 
     #t) 
  (func 1 2)

When run with auto-compilation on, it gives a valid warning during the compilation
step but returns a confusing warning at runtime.

;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 
;;;       or pass the --no-auto-compile argument to disable. 
;;; compiling /home/mike/Projects/pip-tui/pip-tui/bug.scm 
;;; /home/mike/Projects/pip-tui/pip-tui/bug.scm:6:0: warning: wrong number of arguments to `func' 
;;; compiled /home/mike/.cache/guile/ccache/2.0-LE-8-2.0/home/mike/Projects/pip-tui/pip-tui/bug.scm.go 
Backtrace: 
In ice-9/boot-9.scm: 
157: 7 [catch #t #<catch-closure 56422c2dade0> ...] 
In unknown file: 
?: 6 [apply-smob/1 #<catch-closure 56422c2dade0>] 
In ice-9/boot-9.scm: 
63: 5 [call-with-prompt prompt0 ...] 
In ice-9/eval.scm: 
432: 4 [eval # #] 
In ice-9/boot-9.scm: 
2401: 3 [save-module-excursion #<procedure 56422c2f6a00 at ice-9/boot-9.scm:4045:3 ()>] 
4052: 2 [#<procedure 56422c2f6a00 at ice-9/boot-9.scm:4045:3 ()>] 
In unknown file: 
?: 1 [load-compiled/vm "/home/mike/.cache/guile/ccache/2.0-LE-8-2.0/home/mike/Projects/pip-tui/pip-tui/bug.scm.go"] 
In /home/mike/Projects/pip-tui/pip-tui/bug.scm: 
3: 0 [func 1 #<undefined> 2] 

/home/mike/Projects/pip-tui/pip-tui/bug.scm:3:0: In procedure func: 
/home/mike/Projects/pip-tui/pip-tui/bug.scm:3:0: Error while printing exception



When run with GUILE_AUTO_COMPILE=0 it returns an intelligible warning:

Backtrace: 
In ice-9/boot-9.scm: 
157: 9 [catch #t #<catch-closure 560f68600020> ...] 
In unknown file: 
?: 8 [apply-smob/1 #<catch-closure 560f68600020>] 
In ice-9/boot-9.scm: 
63: 7 [call-with-prompt prompt0 ...] 
In ice-9/eval.scm: 
432: 6 [eval # #] 
In ice-9/boot-9.scm: 
2401: 5 [save-module-excursion #<procedure 560f68620a00 at ice-9/boot-9.scm:4045:3 ()>] 
4052: 4 [#<procedure 560f68620a00 at ice-9/boot-9.scm:4045:3 ()>] 
1724: 3 [%start-stack load-stack ...] 
1729: 2 [#<procedure 560f68638fc0 ()>] 
In unknown file: 
?: 1 [primitive-load "/home/mike/Projects/pip-tui/pip-tui/bug.scm"] 
?: 0 [scm-error keyword-argument-error "eval" "Invalid keyword" () (2)] 

ERROR: In procedure scm-error: 
ERROR: Invalid keyword: 2



I can create some improvement by replacing the 'keyword-error-printer'
procedure in ice-9/boot-9.scm with the following
but I don't think that is the correct answer.

--- ice-9/boot-9.scm.0  2016-06-22 00:37:38.929112125 -0400 
+++ ice-9/boot-9.scm    2016-06-22 01:02:11.032206795 -0400 
@@ -1020,8 +1020,10 @@ 

(define (keyword-error-printer port key args default-printer) 
(let ((message (cadr args)) 
-          (faulty  (car (cadddr args)))) ; I won't do it again, I promise. 
-      (format port "~a: ~s" message faulty))) 
+          (faulty (cadddr args))) 
+      (if (pair? faulty) 
+          (format port "~a: ~s" message (car faulty)) 
+          (format port "~a" message)))) 




Reply sent to Andy Wingo <wingo <at> pobox.com>:
You have taken responsibility. (Tue, 28 Feb 2017 21:04:02 GMT) Full text and rfc822 format available.

Notification sent to Mike Gran <spk121 <at> yahoo.com>:
bug acknowledged by developer. (Tue, 28 Feb 2017 21:04:02 GMT) Full text and rfc822 format available.

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

From: Andy Wingo <wingo <at> pobox.com>
To: Mike Gran <spk121 <at> yahoo.com>
Cc: 23821-done <at> debbugs.gnu.org
Subject: Re: bug#23821: Misleading error for optargs
Date: Tue, 28 Feb 2017 22:03:10 +0100
On Wed 22 Jun 2016 07:03, Mike Gran <spk121 <at> yahoo.com> writes:

> The following program returns a confusing error with guile 2.0.11
>
>   (use-modules (ice-9 optargs)) 
>   (define* (func A #:key B) 
>      #t) 
>   (func 1 2)

I have now fixed this in 2.0 and master.  In master it led me to
discover a pretty serious bug.  Now what you get at run-time is:

  wingo <at> clucks:~/src/guile$ meta/guile /tmp/foo.scm
  ;;; note: source file /tmp/foo.scm
  ;;;       newer than compiled /home/wingo/src/guile/cache/guile/ccache/2.2-LE-8-3.9/tmp/foo.scm.go
  ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
  ;;;       or pass the --no-auto-compile argument to disable.
  ;;; compiling /tmp/foo.scm
  ;;; /tmp/foo.scm:4:4: warning: wrong number of arguments to `func'
  ;;; compiled /home/wingo/src/guile/cache/guile/ccache/2.2-LE-8-3.9/tmp/foo.scm.go
  Backtrace:
             6 (apply-smob/1 #<catch-closure 8730a0>)
  In ice-9/boot-9.scm:
      713:2  5 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
  In ice-9/eval.scm:
      619:8  4 (_ #(#(#<directory (guile-user) 8eb6c0>)))
  In ice-9/boot-9.scm:
     2346:4  3 (save-module-excursion _)
    3843:12  2 (_)
  In /tmp/foo.scm:
        4:4  1 (_)
        2:0  0 (func _ #:B _)

  /tmp/foo.scm:2:0: In procedure func:
  /tmp/foo.scm:2:0: Invalid keyword: 2

Which seems OK.

Andy




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 29 Mar 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 141 days ago.

Previous Next


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