mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
Better errors for odd-length keyword args
* libguile/vm-engine.c (bind-kwargs): * libguile/vm.c (vm_error_kwargs_missing_value): * libguile/eval.c (error_missing_value) (prepare_boot_closure_env_for_apply): Adapt to mirror VM behavior. * libguile/keywords.c (scm_c_bind_keyword_arguments): Likewise. * module/ice-9/eval.scm (primitive-eval): Update to error on (foo #:kw) with a "Keyword argument has no value" instead of the horrible "odd argument list length". Also adapts to the expected args format for the keyword-argument-error exception printer in all cases. Matches 1.8 optargs behavior also. * test-suite/standalone/test-scm-c-bind-keyword-arguments.c (test_missing_value): (missing_value_error_handler): Update test. * test-suite/tests/optargs.test: Add tests.
This commit is contained in:
parent
33514ffe22
commit
68f13adaaf
7 changed files with 120 additions and 70 deletions
|
@ -1269,9 +1269,6 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
while (n < ntotal)
|
||||
FP_SET (n++, SCM_UNDEFINED);
|
||||
|
||||
VM_ASSERT (has_rest || (nkw % 2) == 0,
|
||||
vm_error_kwargs_length_not_even (FP_REF (0)));
|
||||
|
||||
/* Now bind keywords, in the order given. */
|
||||
for (n = 0; n < nkw; n++)
|
||||
if (scm_is_keyword (FP_REF (ntotal + n)))
|
||||
|
@ -1281,8 +1278,14 @@ VM_NAME (scm_i_thread *thread, struct scm_vm *vp,
|
|||
if (scm_is_eq (SCM_CAAR (walk), FP_REF (ntotal + n)))
|
||||
{
|
||||
SCM si = SCM_CDAR (walk);
|
||||
FP_SET (SCM_I_INUMP (si) ? SCM_I_INUM (si) : scm_to_uint32 (si),
|
||||
FP_REF (ntotal + n + 1));
|
||||
if (n + 1 < nkw)
|
||||
{
|
||||
FP_SET (SCM_I_INUMP (si) ? SCM_I_INUM (si) : scm_to_uint32 (si),
|
||||
FP_REF (ntotal + n + 1));
|
||||
}
|
||||
else
|
||||
vm_error_kwargs_missing_value (FP_REF (0),
|
||||
FP_REF (ntotal + n));
|
||||
break;
|
||||
}
|
||||
VM_ASSERT (scm_is_pair (walk) || allow_other_keys,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue