Skip to content

Incorrect types for call-with-exception-handler #1505

@cloudrac3r

Description

@cloudrac3r

(1) This should work but doesn't, with an unhelpful error:

#lang typed/racket/base
(: example-1 : -> Void)
(define (example-1)
  (call-with-exception-handler
   (λ (e)
     (println "the handler")
     e)
   (λ ()
     (println "the message"))))

(2) This could be better:

#lang typed/racket/base
(define (example-2)
  (call-with-exception-handler
   (λ (e) e)
   (λ ()
     (+ 2 2))))

> example-2
- : (-> Any) ;; this would be more accurate as : (-> Positive-Index)

I can fix this with this, which seems sound:

(require/typed/provide racket/base
  [call-with-exception-handler (∀ (A) ((Any -> Any) (-> A) -> A))])

I don't understand the syntax of base-env.rkt so I'm not sure how to PR this fix myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions