contract stronger fix for contract structs

This commit is contained in:
Robby Findler 2012-04-05 23:16:43 -05:00
parent f6a8024aed
commit aaa15946fc
3 changed files with 30 additions and 9 deletions

View File

@ -82,11 +82,14 @@ which are then called when the contract's fields are explored
[(id (x ...) ctc-exp)
(and (identifier? (syntax id))
(andmap identifier? (syntax->list (syntax (x ...)))))
(let ([maker-arg #`(λ #,(match-up (reverse prior-ac-ids)
(syntax (x ...))
field-names)
#,(defeat-inlining
#`(#,coerce-contract '#,name ctc-exp)))])
(let* ([proc-name (string->symbol (string-append (symbol->string (syntax-e #'id)) "-dep-proc"))]
[maker-arg #`(let ([#,proc-name
(λ #,(match-up (reverse prior-ac-ids)
(syntax (x ...))
field-names)
#,(defeat-inlining
#`(#,coerce-contract '#,name ctc-exp)))])
#,proc-name)])
(loop (cdr clauses)
(cdr ac-ids)
(cons (car ac-ids) prior-ac-ids)

View File

@ -232,9 +232,18 @@ it around flattened out.
(define (stronger-lazy-contract? a b)
(and (contract-predicate b)
(contract-stronger?
(contract-get a selector-indices)
(contract-get b selector-indices)) ...))
(let ([a-sel (contract-get a selector-indices)]
[b-sel (contract-get b selector-indices)])
(if (contract-struct? a-sel)
(if (contract-struct? b-sel)
(contract-stronger? a-sel b-sel)
#f)
(if (contract-struct? b-sel)
#f
(begin
(printf "comparing ~s ~s ~s\n" a-sel b-sel (procedure-closure-contents-eq? a-sel b-sel))
(procedure-closure-contents-eq? a-sel b-sel)))))
...))
(define (lazy-contract-proj ctc)
(λ (blame)

View File

@ -8770,6 +8770,7 @@
(contract-eval '(define-contract-struct couple (hd tl)))
(contract-eval '(contract-struct triple (a b c)))
(test/spec-passed
'd-c-s-match1
@ -9205,6 +9206,7 @@
'#t)
;
;
;
@ -10410,7 +10412,14 @@ so that propagation occurs.
(,test #f contract-stronger? (short-sorted-list/less-than 5) (short-sorted-list/less-than 4))
(,test #t contract-stronger? (sorted-list/less-than 4) (sorted-list/less-than 5))
(,test #f contract-stronger? (sorted-list/less-than 5) (sorted-list/less-than 4))
(,test #t contract-stronger? (closure-comparison-test 4) (closure-comparison-test 5))))
(,test #t contract-stronger? (closure-comparison-test 4) (closure-comparison-test 5))
(letrec ([mk-c
(λ (x)
(triple/dc [a (<=/c x)]
[b any/c]
[c (a b) (or/c #f (mk-c a))]))])
(,test #t contract-stronger? (mk-c 1) (mk-c 2)))))