cl_parse_key: correctly handle literal allow-other-keys keyword arguments

When parsing keyword arguments of functions like

(defun f (&key allow-other-keys) allow-other-keys)

(note that `&key allow-other-keys` is not `&allow-other-keys`!), we
were incorrectly handling the case in which this function was called
like

(f :some-unknown-keyword x :allow-other-keys non-nil-value)

In this case, the spec (CLHS 3.4.1.4) says that the function has to
ignore the unknown keyword and return the non-nil-value, while we were
signaling an "unknown keyword" error.
This commit is contained in:
Marius Gerbershagen 2021-03-07 19:21:35 +01:00
parent 3ec1ed2ce0
commit a7e1bf6c9f

View file

@ -216,6 +216,12 @@ cl_parse_key(
FEprogram_error("Odd number of keys", 0);
if (ecl_unlikely(unknown_keyword != OBJNULL && !allow_other_keys &&
(supplied_allow_other_keys == ECL_NIL ||
supplied_allow_other_keys == OBJNULL)))
supplied_allow_other_keys == OBJNULL))) {
for (i = 0; i < nkey; i++) {
if (keys[i] == @':allow-other-keys' && vars[nkey+i] == ECL_T && !Null(vars[i])) {
return;
}
}
FEprogram_error("Unknown keyword ~S", 1, unknown_keyword);
}
}