[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #34102] Incorrect procedure arities with Guile 2.x if no compilatio
From: |
Stefan Israelsson Tampe |
Subject: |
[bug #34102] Incorrect procedure arities with Guile 2.x if no compilation |
Date: |
Thu, 25 Aug 2011 14:17:52 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0 |
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/