Recognize cons? and empty? in contract coercion
This commit is contained in:
parent
f5eb600dd7
commit
3825a133ad
|
@ -2,6 +2,7 @@
|
|||
|
||||
(require racket/contract
|
||||
racket/contract/private/generate-base
|
||||
(only-in racket/list empty? cons?)
|
||||
rackunit
|
||||
racket/math
|
||||
(for-syntax racket/base))
|
||||
|
@ -112,6 +113,21 @@
|
|||
(test-contract-generation
|
||||
null?)))
|
||||
|
||||
(check-not-exn
|
||||
(λ ()
|
||||
(test-contract-generation
|
||||
empty?)))
|
||||
|
||||
(check-not-exn
|
||||
(λ ()
|
||||
(test-contract-generation
|
||||
pair?)))
|
||||
|
||||
(check-not-exn
|
||||
(λ ()
|
||||
(test-contract-generation
|
||||
cons?)))
|
||||
|
||||
(check-not-exn
|
||||
(λ ()
|
||||
(test-contract-generation
|
||||
|
|
|
@ -366,12 +366,14 @@
|
|||
[(and (procedure? x) (procedure-arity-includes? x 1))
|
||||
(cond
|
||||
[(chaperone-of? x null?) list/c-empty]
|
||||
[(chaperone-of? x empty?) list/c-empty]
|
||||
[(chaperone-of? x list?)
|
||||
(unless listof-any
|
||||
(error 'coerce-contract/f::listof-any "too soon!"))
|
||||
listof-any]
|
||||
[(chaperone-of? x boolean?) boolean?/c]
|
||||
[(chaperone-of? x pair?)
|
||||
[(or (chaperone-of? x pair?)
|
||||
(chaperone-of? x cons?))
|
||||
(unless consc-anyany
|
||||
(error 'coerce-contract/f::consc-anyany "too soon!"))
|
||||
consc-anyany]
|
||||
|
|
Loading…
Reference in New Issue
Block a user