diff --git a/collects/scheme/private/contract.ss b/collects/scheme/private/contract.ss index c8d3d878b8..729fe92bf2 100644 --- a/collects/scheme/private/contract.ss +++ b/collects/scheme/private/contract.ss @@ -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) diff --git a/collects/scribblings/reference/contracts.scrbl b/collects/scribblings/reference/contracts.scrbl index 675feb7906..1f5053a8c6 100644 --- a/collects/scribblings/reference/contracts.scrbl +++ b/collects/scribblings/reference/contracts.scrbl @@ -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. }