Skip to content
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

Recursive type Problem #957

Closed
NoahStoryM opened this issue Aug 6, 2020 · 0 comments · Fixed by #984
Closed

Recursive type Problem #957

NoahStoryM opened this issue Aug 6, 2020 · 0 comments · Fixed by #984
Labels

Comments

@NoahStoryM
Copy link
Contributor

What version of Racket are you using?

Racket 7.7-1

What program did you run?

#lang typed/racket
(define-type Func (All (A) [-> Func A]))
(: test-func [-> Number Number])
(define test-func
  (λ (num)
    ((λ (func) num)
     (λ ([func : Func])
       (inst func Number)))))

What should have happened?

(test-func 0)   ; -> 0
(test-func 1)   ; -> 1
(test-func 2)   ; -> 2
(test-func 3)   ; -> 3
(test-func 4)   ; -> 4

And following codes work well:

#lang typed/racket
(define-type Func (All (A) [-> Func A]))
(: test-func [-> Number Number])
(define test-func
  (λ (num)
    ((λ (func) num)
     (λ ([func : (Func Number)])
       func))))
#lang typed/racket
(define-type Func (All (A) [-> Boolean Number Any A]))
(: test-func [-> Number Number])
(define test-func
  (λ (num)
    ((λ (func) num)
     (λ ([func : Func])
       (inst func Number)))))

If you got an error message, please include it here.

Type Checker: Cannot instantiate non-polymorphic type Func
  in: func
capfredf added a commit to capfredf/typed-racket that referenced this issue Oct 22, 2020
capfredf added a commit to capfredf/typed-racket that referenced this issue Oct 22, 2020
capfredf added a commit to capfredf/typed-racket that referenced this issue Oct 22, 2020
@capfredf capfredf mentioned this issue Oct 22, 2020
capfredf added a commit to capfredf/typed-racket that referenced this issue Oct 22, 2020
Fix racket#957.

The type representation of an expression, which `inst` is applied
to, could be a Name or it is a Recurive type. In both case, we should call
resolve before actually instantiating it.
samth pushed a commit that referenced this issue Oct 23, 2020
Fix #957.

The type representation of an expression, which `inst` is applied
to, could be a Name or it is a Recurive type. In both case, we should call
resolve before actually instantiating it.
@jackfirth jackfirth added the bug label Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants