mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Fix multi-arity dispatch in GOOPS
* module/oop/goops.scm (multiple-arity-dispatcher): Fix dispatch for max-arity+1 when a generic is already in multiple-arity dispatch. Fixes #24454. * test-suite/tests/goops.test ("dispatch"): Add test.
This commit is contained in:
parent
4dcc97288d
commit
c7fb87cd6e
2 changed files with 12 additions and 1 deletions
|
@ -1333,7 +1333,7 @@ function."
|
|||
#`(case-lambda
|
||||
#,@(build-clauses #'(arg ...))
|
||||
(args (apply miss args)))))))
|
||||
(arity-case (vector-length fv) 20 dispatch
|
||||
(arity-case (1- (vector-length fv)) 20 dispatch
|
||||
(lambda args
|
||||
(let ((nargs (length args)))
|
||||
(if (< nargs (vector-length fv))
|
||||
|
|
|
@ -690,3 +690,14 @@
|
|||
(class (<a>) (slot) #:name '<static-sub> #:static-slot-allocation? #t))
|
||||
(pass-if-equal "non-static subclass" '(a d)
|
||||
(map slot-definition-name (class-slots (class (<a>) (d) #:name '<ad>))))))
|
||||
|
||||
(with-test-prefix "dispatch"
|
||||
(pass-if-equal "multi-arity dispatch" 0
|
||||
(eval '(begin
|
||||
(define-method (dispatch (x <number>) . args) 0)
|
||||
(dispatch 1)
|
||||
(dispatch 1 2)
|
||||
;; By now "dispatch" is forced into multi-arity mode. Test
|
||||
;; that the multi-arity dispatcher works:
|
||||
(dispatch 1 2 3))
|
||||
(current-module))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue