* [bug #34102] Incorrect procedure arities with Guile 2.x if no compilation
@ 2011-08-23 10:33 Patrick Bernaud
2011-08-25 14:17 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 7+ messages in thread
From: Patrick Bernaud @ 2011-08-23 10:33 UTC (permalink / raw)
To: Patrick Bernaud, bug-guile
URL:
<http://savannah.gnu.org/bugs/?34102>
Summary: Incorrect procedure arities with Guile 2.x if no
compilation
Project: Guile
Submitted by: patb
Submitted on: Tue 23 Aug 2011 12:33:23 PM CEST
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
If Guile is run without auto-compilation, the arities of the procedures having
a rest or an optional parameter are wrong.
With the test script attached:
$ guile -v | head -1
guile (GNU Guile) 2.0.2.50-b8287
$ guile --fresh-auto-compile --no-auto-compile -s test.scm
(2 0 #f)
(0 0 #t)
(0 0 #t)
$ guile --auto-compile -s test.scm
(2 0 #f)
(2 0 #t)
(2 1 #f)
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Tue 23 Aug 2011 12:33:23 PM CEST Name: test.scm Size: 267B By: patb
<http://savannah.gnu.org/bugs/download.php?file_id=23852>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug #34102] Incorrect procedure arities with Guile 2.x if no compilation
2011-08-23 10:33 [bug #34102] Incorrect procedure arities with Guile 2.x if no compilation Patrick Bernaud
@ 2011-08-25 14:17 ` Stefan Israelsson Tampe
2011-08-27 13:16 ` [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity) Andy Wingo
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Israelsson Tampe @ 2011-08-25 14:17 UTC (permalink / raw)
To: Stefan Israelsson Tampe, Patrick Bernaud, bug-guile
Follow-up Comment #1, bug #34102 (project guile):
Note,
scheme@(guile-user)> (compile '(define (f x . l) x) #:env (current-module))
scheme@(guile-user)> (procedure-minimum-arity f)
$1 = (1 0 #t)
scheme@(guile-user)> (eval '(define (f x . l) x) (current-module))
$2 = #<variable 27320a0 value: #<procedure 24f37e0 at ice-9/eval.scm:238:6
%args>>
scheme@(guile-user)> (procedure-minimum-arity f)
$3 = (0 0 #t)
So there must be a bug in the eval code!
Diving into eval.scm one can see that the more advanced
lambdas will be translated into (lambda %args ...) e.g.
(define (make-general-closure env body nreq rest? nopt kw inits alt)
(define alt-proc
(and alt
(let* ((body (car alt))
(nreq (cadr alt))
(rest (if (null? (cddr alt)) #f (caddr alt)))
(tail (and (pair? (cddr alt)) (pair? (cdddr alt)) (cdddr
alt)))
(nopt (if tail (car tail) 0))
(kw (and tail (cadr tail)))
(inits (if tail (caddr tail) '()))
(alt (and tail (cadddr tail))))
(make-general-closure env body nreq rest nopt kw inits alt))))
(lambda %args
(let lp ((env env)
(nreq* nreq)
(args %args)) ...
So in alles e.g. (procedure-minimum-arity test2) will see
(lambda x ...) signature and issue the resulting faulty signature
information.
A solution would be to keep a weak hashtable from lambdas to signature
information. The the above function procedure-mi... could first ask that map
for a signature information and if that fails use the old method assuming that
make-general-closure will
populate the weak map correctly.
/Stefan
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity)
2011-08-25 14:17 ` Stefan Israelsson Tampe
@ 2011-08-27 13:16 ` Andy Wingo
2011-08-30 8:57 ` Patrick Bernaud
0 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2011-08-27 13:16 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, Patrick Bernaud, bug-guile
Update of bug #34102 (project guile):
Summary: Incorrect procedure arities with Guile 2.x if no
compilation => improve debuggability of interpreted procedures
(procedure-minimum-arity)
_______________________________________________________
Follow-up Comment #2:
This is a known issue, but the arities are not incorrect, strictly speaking.
The procedure is called "minimum-arity", after all -- it does not claim to be
the most exact arity.
So, this is not a bug. Strictly speaking it is an enhancement request, to
improve the debuggability of interpreted procedures. I am changing the title
to reflect that.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity)
2011-08-27 13:16 ` [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity) Andy Wingo
@ 2011-08-30 8:57 ` Patrick Bernaud
2011-08-31 12:29 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 7+ messages in thread
From: Patrick Bernaud @ 2011-08-30 8:57 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, Patrick Bernaud, bug-guile
Follow-up Comment #3, bug #34102 (project guile):
A procedure of n arguments and a rest has to be passed at least n arguments.
Yet this lowest limit can not be expressed by the rest boolean returned by
'procedure-minimum-arity'.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity)
2011-08-30 8:57 ` Patrick Bernaud
@ 2011-08-31 12:29 ` Stefan Israelsson Tampe
2011-11-15 22:45 ` bug#10059: " Andy Wingo
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Israelsson Tampe @ 2011-08-31 12:29 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, Patrick Bernaud, bug-guile
Follow-up Comment #4, bug #34102 (project guile):
With the following applied git-diff (arity.diff) we get:
~/stis/src/guile/meta/guile --fresh-auto-compile --no-auto-compile -s
arity.scm
(2 0 #f)
(2 0 #t)
(2 1 #f)
And the bug/feature request is fixed!
/Stefan
(file #23913)
_______________________________________________________
Additional Item Attachment:
File name: arity.diff Size:3 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34102>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#10059: [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity)
2011-08-31 12:29 ` Stefan Israelsson Tampe
@ 2011-11-15 22:45 ` Andy Wingo
[not found] ` <handler.10059.B.132139723619652.ack@debbugs.gnu.org>
0 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2011-11-15 22:45 UTC (permalink / raw)
To: stefan.itampe, patrickb, 10059
On Wed 31 Aug 2011 14:29, Stefan Israelsson Tampe <INVALID.NOREPLY@gnu.org> writes:
> Follow-up Comment #4, bug #34102 (project guile):
>
> With the following applied git-diff (arity.diff) we get:
>
> ~/stis/src/guile/meta/guile --fresh-auto-compile --no-auto-compile -s
> arity.scm
> (2 0 #f)
> (2 0 #t)
> (2 1 #f)
>
> And the bug/feature request is fixed!
>
> /Stefan
Thanks for the patch, Stefan! I reworked it a bit and applied it. I
also made it so that procedures defined at the toplevel in `eval' get
their names set appropriately.
I am having trouble with savannah right now, so I am not yet able to
close the bug.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#10059: fixed
[not found] ` <handler.10059.B.132139723619652.ack@debbugs.gnu.org>
@ 2011-11-15 23:01 ` Andy Wingo
0 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2011-11-15 23:01 UTC (permalink / raw)
To: 10059-done
Fixed, whenever I can push this to sv (having connectivity issues now).
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-11-15 23:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-23 10:33 [bug #34102] Incorrect procedure arities with Guile 2.x if no compilation Patrick Bernaud
2011-08-25 14:17 ` Stefan Israelsson Tampe
2011-08-27 13:16 ` [bug #34102] improve debuggability of interpreted procedures (procedure-minimum-arity) Andy Wingo
2011-08-30 8:57 ` Patrick Bernaud
2011-08-31 12:29 ` Stefan Israelsson Tampe
2011-11-15 22:45 ` bug#10059: " Andy Wingo
[not found] ` <handler.10059.B.132139723619652.ack@debbugs.gnu.org>
2011-11-15 23:01 ` bug#10059: fixed 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).