-
-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
prop:chaperone-contract
and recursive-contract
interact unexpectedly creating a nonsensical chaperone error
#4921
Comments
prop:chaperone-contract
generates a contract with improperly wrapped chaperonesprop:chaperone-contract
and recursive-contract
interact unexpectedly creating a nonsensical chaperone error
If you add: #:guard (λ (range name)
(coerce-chaperone-contract 'range-arrow range)) to the definition of
(You should also always use The documentation for #lang racket
(struct range-arrow (range)
#:guard (λ (range name)
(coerce-chaperone-contract 'range-arrow range))
#:property prop:chaperone-contract
(build-chaperone-contract-property
#:late-neg-projection
(λ (arr)
(let* ([range-ctc (get/build-late-neg-projection (range-arrow-range arr))])
(λ (blame)
(λ (f neg-party)
(chaperone-procedure f
(λ (arg)
(values
(λ (answer)
((range-ctc blame) answer neg-party))
arg)))))))))
(define seq/c (or/c null? (cons/c any/c (recursive-contract seq/c #:flat))))
(define (run-plain f) (f 'yay))
(define/contract run-good1 (-> (-> any/c (-> seq/c)) any/c) run-plain)
(define/contract run-good2 (-> (-> any/c (-> (listof any/c))) any/c) run-plain)
(define/contract run-good3 (-> (-> any/c (-> list?)) any/c) run-plain)
(define/contract run-bad (-> (range-arrow (-> seq/c)) any/c) run-plain)
((run-plain (λ (a) (λ () (list a))))) ; => '(yay)
((run-good1 (λ (a) (λ () (list a))))) ; => '(yay)
((run-good2 (λ (a) (λ () (list a))))) ; => '(yay)
((run-good3 (λ (a) (λ () (list a))))) ; => '(yay)
((run-bad (λ (a) (λ () (list a))))) ; => '(yay) |
@LiberalArtist Thank you for your suggestions, unfortunately neither of them are applicable for my actual contract combinator but posting ~450 lines of code (including tests) seemed like a bad idea so I simplified it as much as possible while still generating the same error. Specifically It turns out that telling |
The problem was that in your example, Admittedly,
is a very cryptic error message (and the That error message is constructed for BC at racket/racket/src/bc/src/error.c Lines 2264 to 2278 in 901a313
racket/racket/src/cs/rumble/impersonator.ss Lines 17 to 25 in 901a313
(For CS,
If your combinator is supposed to create chaperone contracts, it needs to use That leads us to the bug in The Racket Guide. While the prose here correctly says to use racket/pkgs/racket-doc/scribblings/guide/contracts/new-combinators.scrbl Lines 291 to 299 in 901a313
racket/pkgs/racket-doc/scribblings/guide/contracts/new-combinators.scrbl Lines 472 to 474 in 901a313
|
What version of Racket are you using?
e.g., 8.11.1 [cs]
What program did you run?
The following chaperone contract is made following the tutorial in the racket guide, at which point I noticed the bug and then simplified it as much as possible while still being able to trigger the bug.
What should have happened?
We should get the value
'(yay)
printed five times.If you got an error message, please include it here.
Please include any other relevant details
It looks like the procedure being passed to the
range-list-arrow
contract is not being chaperoned correctly? Based on how therun-good
examples work as expected, it seems to be an unintended interaction between the recursive nature ofseq/c
and the custom contract.The text was updated successfully, but these errors were encountered: