unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#23821: Misleading error for optargs
       [not found] <738648054.2214015.1466571839142.JavaMail.yahoo.ref@mail.yahoo.com>
@ 2016-06-22  5:03 ` Mike Gran
  2017-02-28 21:03   ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Mike Gran @ 2016-06-22  5:03 UTC (permalink / raw)
  To: 23821

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)))) 





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#23821: Misleading error for optargs
  2016-06-22  5:03 ` bug#23821: Misleading error for optargs Mike Gran
@ 2017-02-28 21:03   ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2017-02-28 21:03 UTC (permalink / raw)
  To: Mike Gran; +Cc: 23821-done

On Wed 22 Jun 2016 07:03, Mike Gran <spk121@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@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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-28 21:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <738648054.2214015.1466571839142.JavaMail.yahoo.ref@mail.yahoo.com>
2016-06-22  5:03 ` bug#23821: Misleading error for optargs Mike Gran
2017-02-28 21:03   ` Andy Wingo

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).