racket / racket/racket

`value-contract` is sometimes wrong with collapsibles

Open
#4,015 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: contract
Dominant language
Racket
Stars
5.2k
Forks
698
Avg merge
18h 34m
Merged PRs (30d)
5

Description

What version of Racket are you using?
8.2

What program did you run?

(define my-arrow/c
  (make-contract
   #:name 'my-arrow/c
   #:projection
   (λ (blm)
     (λ (val)
       (chaperone-procedure
        val
        values
        impersonator-prop:contracted
        my-arrow/c)))))

(define/contract (foo x)
  (and/c my-arrow/c (-> integer? integer?))
  x)

(value-contract foo)

What should have happened?

Should output (-> integer? integer?) since the second conjunct's wrapper is on the outside. Instead, you get #<contract: my-arrow/c>.

Please include any other relevant details

Within value-contract there is a cond that determines which property to use to retrieve the contract. We get this behavior since collapsibles don't actually set impersonator-prop:contracted and because of the way those cond arms are ordered.

It seems like setting impersonator-prop:contracted would be the right fix here, although given how this code is written, there might be some reason why that's not being done already.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied Racket program first, then read racket/collects/racket/contract/private/guts.rkt around the value-contract cond and racket/collects/racket/contract/private/arrow-higher-order.rkt around line 659. Trace how collapsibles expose contract properties and verify that value-contract selects the outer arrow contract rather than my-arrow/c. Done means the example reports (-> integer? integer?).

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.