diff --git a/racket/collects/racket/match/gen-match.rkt b/racket/collects/racket/match/gen-match.rkt index ecf86c4e44..393cde3820 100644 --- a/racket/collects/racket/match/gen-match.rkt +++ b/racket/collects/racket/match/gen-match.rkt @@ -26,6 +26,12 @@ (parameterize ([orig-stx stx]) (unless (syntax->list es) (raise-syntax-error 'match* "expected a sequence of expressions to match" es))) + (define/with-syntax form-name + (syntax-case stx () + [(fname . _) + (identifier? #'fname) + (syntax-e #'fname)] + [_ 'match])) (define len (length (syntax->list es))) (define srcloc-list (list #`(quote #,(syntax-source stx)) #`(quote #,(syntax-line stx)) @@ -36,7 +42,7 @@ (define/with-syntax (exprs ...) es) (define/with-syntax outer-fail (generate-temporary #'fail)) (define/with-syntax orig-expr (if (= 1 len) (stx-car #'(xs ...)) #'(list xs ...))) - (define/with-syntax raise-error (quasisyntax/loc stx (match:error orig-expr (list (srcloc #,@srcloc-list))))) + (define/with-syntax raise-error (quasisyntax/loc stx (match:error orig-expr (list (srcloc #,@srcloc-list)) 'form-name))) (define parsed-clauses (for/list ([clause (syntax->list clauses)] [pats (syntax->list #'(pats ...))] diff --git a/racket/collects/racket/match/runtime.rkt b/racket/collects/racket/match/runtime.rkt index 677a48619f..e0dc26f524 100644 --- a/racket/collects/racket/match/runtime.rkt +++ b/racket/collects/racket/match/runtime.rkt @@ -18,8 +18,8 @@ #:property prop:exn:srclocs (lambda (ex) (exn:misc:match-srclocs ex))) -(define (match:error val srclocs) - (raise (make-exn:misc:match (format "match: no matching clause for ~e" val) +(define (match:error val srclocs form-name) + (raise (make-exn:misc:match (format "~a: no matching clause for ~e" form-name val) (current-continuation-marks) val srclocs)))