- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Labels
Description
This program:
#lang typed/racket
(: g (∩ (-> Integer Integer)
(-> Boolean Boolean)))
(define (g x)
(if (exact-integer? x)
5
#f))
produces this error:
Welcome to DrRacket, version 8.3.900 [cs].
Language: typed/racket, with debugging; memory limit: 128 MB.
. Type Checker: type mismatch
expected: (∩ (-> Boolean Boolean) (-> Integer Integer))
given: (-> Any (U False Positive-Byte) : Integer) in: (define (g x) (if (exact-integer? x) 5 #f))
but it seems like, if the rule for intersection types is this,
e : τ1 e : τ2
------------------
e : τ1 ∩ τ2
then it should, because these two programs both type check:
#lang typed/racket
(: g (-> Integer Integer))
(define (g x)
(if (exact-integer? x)
5
#f))
#lang typed/racket
(: g (-> Boolean Boolean))
(define (g x)
(if (exact-integer? x)
5
#f))
capfredf
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity