fix bug introduced recently by special cases for ->

This commit is contained in:
Robby Findler 2012-02-19 16:17:33 -06:00
parent 88bd4cce6c
commit 297db9b305
2 changed files with 28 additions and 0 deletions

View File

@ -2030,12 +2030,14 @@ v4 todo:
(define-syntax (-> stx)
(syntax-case stx (any any/c boolean?)
[(_ any/c ... any)
(not (syntax-parameter-value #'making-a-method))
;; special case the (-> any/c ... any) contracts to be first-order checks only
(with-syntax ([dom-len (- (length (syntax->list stx)) 2)]
[name (syntax->datum stx)])
#'(flat-named-contract 'name (λ (x) (and (procedure? x) (procedure-arity-includes? x dom-len #t)))))]
[(_ any/c boolean?)
;; special case (-> any/c boolean?) to use predicate/c
(not (syntax-parameter-value #'making-a-method))
#'-predicate/c]
[_
#`(syntax-parameterize ((making-a-method #f)) #,(->/proc/main stx))]))

View File

@ -6273,6 +6273,32 @@
m
5))
(test/spec-passed/result
'object-contract/arrow-special-case1
'(send (contract (object-contract
[m (-> any/c boolean?)])
(new (class object%
(define/public (m x) #t)
(super-new)))
'pos
'neg)
m 1)
#t)
(test/spec-passed/result
'object-contract/arrow-special-case2
'(send (contract (object-contract
[m (-> any/c any)])
(new (class object%
(define/public (m x) #t)
(super-new)))
'pos
'neg)
m 1)
#t)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; test error message has right format