Regression in type inference for uses of newly defined sub-type in polymorphic functions
Open
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
What version of Racket are you using?
7.2
What program did you run?
#lang typed/racket/base
(struct (X) Wrap ([content : (Option X)]) #:transparent)
(define-new-subtype New-Int (Integer->New-Int Integer))
(: poly (∀ (X) (X → Any) (Wrap X) → Any))
(define (poly f xs) 'ignore)
(: mono : (New-Int → Any) (Wrap New-Int) → Any)
(define (mono f xs) (poly f xs))
What should have happened?
This program type-checks in 7.0. One of the following changes make the program type check in 7.2:
- Manually instantiate
(inst poly New-Int) - Define
New-Intto just be an alias ofIntegerinstead of sub type - Change
content's type fromOption XtoXorListof X
If you got an error message, please include it here.
; Type Checker: Polymorphic function `poly' could not be applied to arguments:
; Argument 1:
; Expected: (-> X Any)
; Given: (-> New-Int Any)
; Argument 2:
; Expected: (Wrap X)
; Given: (Wrap New-Int)
;
; Result type: Any
; Expected result: Any
;
; in: (poly f xs)
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 #lang typed/racket/base program and inspect the type-checking failure at (poly f xs). Compare inference for Wrap New-Int and the Option X field with the behavior in Racket 7.0. Done means the program type-checks in the normal polymorphic call without manual instantiation or changing the subtype or field type.
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
- 38/100