Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem with the original
case-lambda
tests is that they couldactually pass if the
+
and*
procedures were implemented correctlybut
case-lambda
itself wasn’t.Specifically, an attempted optimized
case-lambda
implementationwhich looked at the length of its arguments list and subsequently
erroneously always chose the variadic clause of the
plus
procedurewould still pass the test, because
plus
in this case recreated thebehaviour of the
+
procedure used for the test; it was neveractually observable whether the
args
clause or one of the morespecific clauses had been used to generate the result. Similar applies
to the
mult
test: although in that case an implementation could onlyhave erroneously chosen the
(x y . z)
clause in the two-argumentcase, it would still have been an error invisible to the test cases.
I’ve also added a test which attempts to ensure that a redundant
clause will never match. This may cause a warning on Schemes which
detect such clauses at compile time, but R7RS does not explicitly
define such
case-lambda
expressions as erroneous in any way, so itwould be wrong (and non-conformant) for it to stop the tests running
altogether.
(This patch mainly useful because Chibi’s R7RS tests are sometimes
used by other implementations to ensure conformance. Chibi passed
these tests in any case.)