diff --git a/collects/redex/private/struct.rkt b/collects/redex/private/struct.rkt index 2b309429d8..5ee5d8bfeb 100644 --- a/collects/redex/private/struct.rkt +++ b/collects/redex/private/struct.rkt @@ -68,20 +68,17 @@ language combined-rules combined-rule-names lws (map (λ (rule) (define specialized (rule language)) + (define (f-with-contract t) + (unless (match-pattern compiled-domain t) + (error 'reduction-relation "relation reduced to ~s via ~a, which is outside its domain" + t + (let ([name (rewrite-proc-name rule)]) + (if name + (format "the rule named ~a" name) + "an unnamed rule")))) + t) (λ (tl-exp exp f acc) (unless (match-pattern compiled-domain tl-exp) (error 'reduction-relation "relation not defined for ~s" tl-exp)) - (let ([ress (specialized tl-exp exp f acc)]) - (for-each - (λ (res) - (let ([term (caddr res)]) - (unless (match-pattern compiled-domain term) - (error 'reduction-relation "relation reduced to ~s via ~a, which is outside its domain" - term - (let ([name (rewrite-proc-name rule)]) - (if name - (format "the rule named ~a" name) - "an unnamed rule")))))) - ress) - ress))) + (specialized tl-exp exp f-with-contract acc))) combined-rules))) diff --git a/collects/redex/tests/tl-test.rkt b/collects/redex/tests/tl-test.rkt index 48d48191cf..a26f7ccaa4 100644 --- a/collects/redex/tests/tl-test.rkt +++ b/collects/redex/tests/tl-test.rkt @@ -1317,6 +1317,14 @@ 'x) (list 'a 'b 'c 'd)) + + (let ([R (reduction-relation empty-language #:domain number (--> 1 a "first"))] + [S (reduction-relation empty-language (--> 2 a "second"))]) + (test (apply-reduction-relation (union-reduction-relations R S) 2) + (list 'a)) + (test (apply-reduction-relation (union-reduction-relations S R) 2) + (list 'a))) + (test (apply-reduction-relation (reduction-relation empty-language