From 327c55a28bc20403962f20a58cce445bff261706 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Mon, 4 Feb 2013 13:03:58 -0500 Subject: [PATCH] Don't special case typechecking of =. Its type is more useful than the special typing rule. original commit: 568f401bdcea778acfa8c1b80f18b23e9e9c9345 --- collects/tests/typed-racket/succeed/num-equal-filter.rkt | 6 ++++++ collects/typed-racket/typecheck/tc-app/tc-app-eq.rkt | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 collects/tests/typed-racket/succeed/num-equal-filter.rkt diff --git a/collects/tests/typed-racket/succeed/num-equal-filter.rkt b/collects/tests/typed-racket/succeed/num-equal-filter.rkt new file mode 100644 index 00000000..f1e9f33a --- /dev/null +++ b/collects/tests/typed-racket/succeed/num-equal-filter.rkt @@ -0,0 +1,6 @@ +#lang typed/racket + +(: f : Nonnegative-Integer -> Boolean) +(define (f x) + (cond [(= 0 x) #t] + [else (f (sub1 x))])) ; here, x is Positive-Integer diff --git a/collects/typed-racket/typecheck/tc-app/tc-app-eq.rkt b/collects/typed-racket/typecheck/tc-app/tc-app-eq.rkt index 97302903..6791fd12 100644 --- a/collects/typed-racket/typecheck/tc-app/tc-app-eq.rkt +++ b/collects/typed-racket/typecheck/tc-app/tc-app-eq.rkt @@ -19,9 +19,10 @@ (export tc-app-eq^) ;; comparators that inform the type system +;; `=' is not included. Its type is more useful than this typing rule. (define-syntax-class comparator - #:literals (eq? equal? eqv? = string=? symbol=? memq member memv) - (pattern eq?) (pattern equal?) (pattern eqv?) (pattern =) (pattern string=?) (pattern symbol=?) + #:literals (eq? equal? eqv? string=? symbol=? memq member memv) + (pattern eq?) (pattern equal?) (pattern eqv?) (pattern string=?) (pattern symbol=?) (pattern member) (pattern memq) (pattern memv)) @@ -46,7 +47,7 @@ (define-syntax-rule (alt nm pred ...) (and (free-identifier=? #'nm comparator) (or (pred val) ...))) (or (alt symbol=? symbol?) - (alt string=? string?) + (alt string=? string?) (alt eq? eq?-able) (alt eqv? eqv?-able) (alt equal? equal?-able)))