define-predicate doesn't work for union type that contains (List Any) type.
Open
Nobody has claimed this yet.
bug
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
What version of Racket are you using?
v7.8
What program did you run?
#lang typed/racket
(define-type Foo (List Any))
(define-predicate foo? Foo)
(define-type Bar-List (Listof Bar))
(define-type Bar (U Foo Bar-List))
(define-predicate bar-list? Bar-List)
(define-predicate bar? Bar)
(displayln (bar? '((1) ((2)) (((3))))))
What should have happened?
#t
It works if we define bar? manually:
(define-predicate bar-list? Bar-List)
(: bar? [-> Any Boolean : Bar])
(define bar?
(λ (arg)
(or (foo? arg)
(bar-list? arg))))
If you got an error message, please include it here.
Type Checker: Type Bar could not be converted to a predicate: required a flat contract but generated a chaperone contract
in: Bar
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Typed Racket program with v7.8 and inspect the define-predicate entry point for unions containing (List Any). Determine why Bar cannot be converted to a flat contract. Done means the example produces #t and regression coverage verifies the behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100