cs: improve error message for define-values
Report the first variable of the `define-values` form, like traditional Racket does.
This commit is contained in:
parent
fa2ef64adb
commit
ec9c30d2f1
|
@ -3158,6 +3158,18 @@ case of module-leve bindings; it doesn't cover local bindings.
|
|||
exn:fail:contract:variable?
|
||||
#rx"struct:spider")))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Make sure error message is right for wrong number of
|
||||
;; values
|
||||
|
||||
(module returns-obviously-wrong-number-of-values-to-definition racket/base
|
||||
(define-values (x y z) (values 1 2 3 4)))
|
||||
|
||||
(err/rt-test/once (dynamic-require ''returns-obviously-wrong-number-of-values-to-definition #f)
|
||||
exn:fail:contract:arity?
|
||||
#rx"define-values: result arity mismatch")
|
||||
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -1107,7 +1107,7 @@
|
|||
(call-with-values proc
|
||||
(lambda vals
|
||||
(unless (= (length syms) (length vals))
|
||||
(raise-binding-result-arity-error syms vals))
|
||||
(raise-definition-result-arity-error syms vals))
|
||||
(let loop ([vars vars] [vals vals] [modes modes])
|
||||
(unless (null? vars)
|
||||
(do-variable-set! (car vars) (car vals) (car modes) #t)
|
||||
|
|
|
@ -201,6 +201,7 @@
|
|||
raise-result-arity-error
|
||||
raise-type-error
|
||||
raise-binding-result-arity-error ; not exported to Racket
|
||||
raise-definition-result-arity-error ; not exported to Racket
|
||||
|
||||
(rename [make-unquoted-printing-string unquoted-printing-string])
|
||||
unquoted-printing-string?
|
||||
|
|
|
@ -431,6 +431,16 @@
|
|||
"\n at: local-binding form"
|
||||
args))
|
||||
|
||||
(define (raise-definition-result-arity-error expected-args args)
|
||||
(apply raise-result-arity-error 'define-values
|
||||
(length expected-args)
|
||||
(if (null? expected-args)
|
||||
""
|
||||
(string-append "\n at: definition of "
|
||||
(symbol->string (car expected-args))
|
||||
" ..."))
|
||||
args))
|
||||
|
||||
(define raise-unsupported-error
|
||||
(case-lambda
|
||||
[(id msg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user