mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
case-lambda* clauses fail to match if too many positionals
* doc/ref/api-procedures.texi (Case-lambda): Expand case-lambda* documentation. * module/ice-9/eval.scm (primitive-eval): * libguile/eval.c (prepare_boot_closure_env_for_apply): Dispatch to the next case-lambda clause if there are too many positionals. * doc/ref/vm.texi (Function Prologue Instructions): * libguile/vm-i-system.c (bind-optionals/shuffle-or-br): New instruction, like bind-optionals/shuffle but can dispatch to the next clause if there are too many positionals. * module/language/assembly/disassemble.scm (code-annotation): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add case for bind-optionals/shuffle-or-br. * module/language/glil/compile-assembly.scm (glil->assembly): If there is an alternate, use bind-optionals/shuffle-or-br instead of bind-optionals/shuffle. * test-suite/tests/optargs.test ("case-lambda*"): Add tests.
This commit is contained in:
parent
18c5bffe96
commit
581f410fbd
10 changed files with 308 additions and 80 deletions
|
@ -1,7 +1,7 @@
|
|||
;;;; optargs.test --- test suite for optional arg processing -*- scheme -*-
|
||||
;;;; Matthias Koeppe <mkoeppe@mail.math.uni-magdeburg.de> --- June 2001
|
||||
;;;;
|
||||
;;;; Copyright (C) 2001, 2006, 2009, 2010 Free Software Foundation, Inc.
|
||||
;;;; Copyright (C) 2001, 2006, 2009, 2010, 2013 Free Software Foundation, Inc.
|
||||
;;;;
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -22,6 +22,9 @@
|
|||
#:use-module (system base compile)
|
||||
#:use-module (ice-9 optargs))
|
||||
|
||||
(define exception:invalid-keyword
|
||||
'(keyword-argument-error . "Invalid keyword"))
|
||||
|
||||
(define exception:unrecognized-keyword
|
||||
'(keyword-argument-error . "Unrecognized keyword"))
|
||||
|
||||
|
@ -217,3 +220,70 @@
|
|||
(pass-if "default arg"
|
||||
(equal? (transmogrify quote)
|
||||
10)))
|
||||
|
||||
(with-test-prefix/c&e "case-lambda*"
|
||||
(pass-if "unambiguous"
|
||||
((case-lambda*
|
||||
((a b) #t)
|
||||
((a) #f))
|
||||
1 2))
|
||||
|
||||
(pass-if "unambiguous (reversed)"
|
||||
((case-lambda*
|
||||
((a) #f)
|
||||
((a b) #t))
|
||||
1 2))
|
||||
|
||||
(pass-if "optionals (order disambiguates)"
|
||||
((case-lambda*
|
||||
((a #:optional b) #t)
|
||||
((a b) #f))
|
||||
1 2))
|
||||
|
||||
(pass-if "optionals (order disambiguates (2))"
|
||||
((case-lambda*
|
||||
((a b) #t)
|
||||
((a #:optional b) #f))
|
||||
1 2))
|
||||
|
||||
(pass-if "optionals (one arg)"
|
||||
((case-lambda*
|
||||
((a b) #f)
|
||||
((a #:optional b) #t))
|
||||
1))
|
||||
|
||||
(pass-if "optionals (one arg (2))"
|
||||
((case-lambda*
|
||||
((a #:optional b) #t)
|
||||
((a b) #f))
|
||||
1))
|
||||
|
||||
(pass-if "keywords without keyword"
|
||||
((case-lambda*
|
||||
((a #:key c) #t)
|
||||
((a b) #f))
|
||||
1))
|
||||
|
||||
(pass-if "keywords with keyword"
|
||||
((case-lambda*
|
||||
((a #:key c) #t)
|
||||
((a b) #f))
|
||||
1 #:c 2))
|
||||
|
||||
(pass-if "keywords (too many positionals)"
|
||||
((case-lambda*
|
||||
((a #:key c) #f)
|
||||
((a b) #t))
|
||||
1 2))
|
||||
|
||||
(pass-if "keywords (order disambiguates)"
|
||||
((case-lambda*
|
||||
((a #:key c) #t)
|
||||
((a b c) #f))
|
||||
1 #:c 2))
|
||||
|
||||
(pass-if "keywords (order disambiguates (2))"
|
||||
((case-lambda*
|
||||
((a b c) #t)
|
||||
((a #:key c) #f))
|
||||
1 #:c 2)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue