bugGuile - Bugs: bug #34102, improve debuggability of...

 
 

bug #34102: improve debuggability of interpreted procedures (procedure-minimum-arity)

Submitted by:  Patrick Bernaud <patb>
Submitted on:  Tue 23 Aug 2011 10:33:23 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 15 Nov 2011 11:04:06 PM UTC, comment #5:

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.

Andy Wingo <wingo>
Project Administrator
Wed 31 Aug 2011 12:29:11 PM UTC, comment #4:

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)

Stefan Israelsson Tampe <tampe>
Project Member
Tue 30 Aug 2011 08:57:11 AM UTC, comment #3:

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

Patrick Bernaud <patb>
Sat 27 Aug 2011 01:16:48 PM UTC, 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.

Andy Wingo <wingo>
Project Administrator
Thu 25 Aug 2011 02:17:51 PM UTC, comment #1:

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

Stefan Israelsson Tampe <tampe>
Project Member
Tue 23 Aug 2011 10:33:23 AM UTC, original submission:

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)

Patrick Bernaud <patb>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #23913:  arity.diff added by tampe (4KiB - text/x-patch - proposed fix)
file #23852:  test.scm added by patb (267B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wingo (Posted a comment)
  • -unavailable- added by tampe (Posted a comment)
  • -unavailable- added by patb (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 15 Nov 2011 11:04:11 PM UTCwingoOpen/ClosedOpen=>Closed
    Tue 15 Nov 2011 11:04:06 PM UTCwingoStatusNone=>Fixed
    Wed 31 Aug 2011 12:29:11 PM UTCtampeAttached File-=>Added arity.diff, #23913
    Sat 27 Aug 2011 01:16:48 PM UTCwingoSummaryIncorrect procedure arities with Guile 2.x if no compilation =>improve debuggability of interpreted procedures (procedure-minimum-arity)
    Tue 23 Aug 2011 10:33:23 AM UTCpatbAttached File-=>Added test.scm, #23852

    Back to the top


    Powered by Savane 3.1-cleanup1