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

 
 

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

Submitter:  Patrick Bernaud <patb>
Submitted:  Tue 23 Aug 2011 10:33:23 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group 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>
Group 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>
Group 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 Files:
   
   
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
  • -email is unavailable- added by wingo (Posted a comment)
  • -email is unavailable- added by tampe (Posted a comment)
  • -email is unavailable- added by patb (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-11-15 wingo Open/ClosedOpen Closed
    2011-11-15 wingo StatusNone Fixed
    2011-08-31 tampe Attached File- Added arity.diff, #23913
    2011-08-27 wingo SummaryIncorrect procedure arities with Guile 2.x if no compilation improve debuggability of interpreted procedures (procedure-minimum-arity)
    2011-08-23 patb Attached File- Added test.scm, #23852

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code