{"action":"closed","issue":{"url":"https://api.github.com/repos/racket/typed-racket/issues/173","repository_url":"https://api.github.com/repos/racket/typed-racket","labels_url":"https://api.github.com/repos/racket/typed-racket/issues/173/labels{/name}","comments_url":"https://api.github.com/repos/racket/typed-racket/issues/173/comments","events_url":"https://api.github.com/repos/racket/typed-racket/issues/173/events","html_url":"https://github.com/racket/typed-racket/issues/173","id":100366453,"number":173,"title":"[polymorphic recursion] Error in macro expansion -- cannot apply a non-polymorphic type: Nothing in: (t X)","user":{"login":"jsmaniac","id":299872,"avatar_url":"https://avatars.githubusercontent.com/u/299872?v=3","gravatar_id":"","url":"https://api.github.com/users/jsmaniac","html_url":"https://github.com/jsmaniac","followers_url":"https://api.github.com/users/jsmaniac/followers","following_url":"https://api.github.com/users/jsmaniac/following{/other_user}","gists_url":"https://api.github.com/users/jsmaniac/gists{/gist_id}","starred_url":"https://api.github.com/users/jsmaniac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsmaniac/subscriptions","organizations_url":"https://api.github.com/users/jsmaniac/orgs","repos_url":"https://api.github.com/users/jsmaniac/repos","events_url":"https://api.github.com/users/jsmaniac/events{/privacy}","received_events_url":"https://api.github.com/users/jsmaniac/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-11T17:42:30Z","updated_at":"2016-05-11T09:53:49Z","closed_at":"2016-05-11T09:53:49Z","body":"This bug happens only when:\r\n* The value's type uses polymorphic recursion\r\n* Displaying the value (or its type?) at the REPL\r\n * But if it gets printed as part of the definitions, it works\r\n * And `(begin (make-n 42) '())` in the REPL works too\r\n * Although `(display (make-n 42))` in the REPL triggers the bug\r\n * But `(display (format \"~a\" (make-n 42)))` does not\r\n* Also, the type must not visible anymore (because it was defined inside a `(let () …)`)\r\n * Removing the `(let ()`, and writing directly `(define make-n (inst make-t Number))` works.\r\n\r\n```scheme\r\n#lang typed/racket\r\n\r\n(define make-n\r\n  (let ()\r\n    (define-type (t A) (∀ (X) (→ X (t X))))\r\n    \r\n    (: make-t (∀ (A) (→ A (t A))))\r\n    (define (make-t a)\r\n      (λ #:∀ (X) (x) ((inst make-t X) x)))\r\n    \r\n    (inst make-t Number)))\r\n\r\n;; Typing the following line at the REPL gives:\r\n;;   Type Checker: Error in macro expansion -- cannot apply a non-polymorphic type: Nothing in: (t X)\r\n;; It works in the code though.\r\n(make-n 42)\r\n```"}}