我正在尝试处理键入的球拍中的某些类型的错误。以下代码在类型化和非类型化 Racket 中均按预期工作
(with-handlers
([exn:fail:contract:divide-by-zero?
(lambda (e)
(raise e))])
(let ([x 0]
[y 1])
(display (/ y x))))
导致错误消息
/: division by zero
在非类型化的 Racket 中进行了一些细微的阐述:
(with-handlers
([exn:fail:contract:divide-by-zero?
(lambda (e)
(displayln "oops!")
(raise e))])
(let ([x 0]
[y 1])
(display (/ y x))))
oops!
/: division by zero
但在键入的 Racket 中给出以下错误消息:
Type Checker: No function domains matched in function application:
Domains: (U (Rec flat (U (Immutable-HashTable flat flat) (Immutable-Vectorof flat) (Pairof flat flat) Boolean Bytes Char Complex Keyword Null String Symbol)) exn) Any
(U (Rec flat (U (Immutable-HashTable flat flat) (Immutable-Vectorof flat) (Pairof flat flat) Boolean Bytes Char Complex Keyword Null String Symbol)) exn)
Arguments: Any
in: (raise e)
有人可以解释一下这里发生了什么,或者提出解决方法吗?