changed the way or/c works; PR 10010

svn: r13030
This commit is contained in:
Robby Findler 2009-01-07 16:48:17 +00:00
parent 2afe7621b3
commit c9ebe9bba3
2 changed files with 11 additions and 9 deletions

View File

@ -966,13 +966,15 @@ improve method arity mismatch contract violation error messages?
(if candidate-proc
(candidate-proc val)
(raise-contract-error val src-info pos-blame orig-str
"none of the branches of the or/c matched"))]
"none of the branches of the or/c matched, given ~e"
val))]
[((car checks) val)
(if candidate-proc
(error 'or/c "two arguments, ~s and ~s, might both match ~s"
(contract-name candidate-contract)
(contract-name (car contracts))
val)
(raise-contract-error val src-info pos-blame orig-str
"two of the clauses in the or/c might both match: ~s and ~s, given ~e"
(contract-name candidate-contract)
(contract-name (car contracts))
val)
(loop (cdr checks)
(cdr procs)
(cdr contracts)

View File

@ -101,14 +101,14 @@ checks all of the @tech{flat contracts}. If none of them pass, it
calls @scheme[contract-first-order-passes?] with each of the
higher-order contracts. If only one returns true, @scheme[or/c] uses
that contract. If none of them return true, it signals a contract
violation. If more than one returns true, it signals an error
indicating that multiple branches of the @scheme[or/c] each might
apply to the value. For example, this contract
violation. If more than one returns true, it also signals a contract
violation.
For example, this contract
@schemeblock[
(or/c (-> number? number?)
(-> string? string? string?))
]
cannot accept a function like this one: @scheme[(lambda args ...)]
does not accept a function like this one: @scheme[(lambda args ...)]
since it cannot tell which of the two arrow contracts should be used
with the function.
}