1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

fix bug in goops' method cache with rest args

* module/oop/goops/compile.scm (code-table-lookup): Fix a tricky little
  bug!

* test-suite/tests/goops.test ("the method cache"): Add a wee test.
This commit is contained in:
Andy Wingo 2009-06-06 14:07:29 +02:00
parent 12798872ff
commit 4bcc952d45
2 changed files with 19 additions and 5 deletions

View file

@ -34,11 +34,12 @@
(define code-table-lookup
(letrec ((check-entry (lambda (entry types)
(if (null? types)
(and (not (struct? (car entry)))
entry)
(and (eq? (car entry) (car types))
(check-entry (cdr entry) (cdr types)))))))
(cond
((not (pair? entry)) (and (null? types) entry))
((null? types) #f)
(else
(and (eq? (car entry) (car types))
(check-entry (cdr entry) (cdr types))))))))
(lambda (code-table types)
(cond ((null? code-table) #f)
((check-entry (car code-table) types))

View file

@ -261,6 +261,19 @@
(method-more-specific? m1 m2 '()))
(current-module))))
(with-test-prefix "the method cache"
(pass-if "defining a method with a rest arg"
(let ((m (current-module)))
(eval '(define-method (foo bar . baz)
(cons bar baz))
m)
(eval '(foo 1)
m)
(eval '(foo 1 2)
m)
(eval '(equal? (foo 1 2) '(1 2))
m))))
(with-test-prefix "defining accessors"
(with-test-prefix "define-accessor"