core.typed

0.2.16 seems to introduce a bug

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    core.typed 0.2.16 and later

Description

Some changes introduced by core.typed-0.2.16 seems to cause `Type Error (sicp.err:49:13) Cannot resolve type: a` for following code.

0.2.15: :ok
0.2.16: error
0.2.17: error
0.2.18: error
0.2.19: error

$ lein typed check sicp.err
Initializing core.typed ...
Loading Clojurescript...
Clojurescript not found
"Elapsed time: 3130.848 msecs"
core.typed initialized.
Start collecting sicp.err
Finished collecting sicp.err
Collected 1 namespaces in 3293.048 msecs
Start checking sicp.err
Type Error (sicp.err:49:13) Cannot resolve type: a
Hint: Is a in scope?
Hint: Has a's annotation been found via check-ns, cf or typed-deps?
Found errors
Subprocess failed
(ns sicp.err
  (:require [clojure.test :refer [is are]]
            [clojure.core.typed :refer [ann fn>
                                        Seqable] :as typed])
  (:import (clojure.lang ASeq LazySeq)))


(ann reduce_ (All [a b] (Fn [[a b
                              -> b]
                             b
                             (Seqable a)
                             -> b]
                            [[a (Seqable (U a b))
                              -> (Seqable (U a b))]
                             (Seqable (U a b))
                             (Seqable a)
                             -> (Seqable (U a b))])))
(defn reduce_
  {:test #(do (is (= (reduce_ +' 0 [1 2]) 3))
              (is (= (reduce_ / 1 [2 3]) 2/3)))}
  [f zero coll]
  (if-let [s (seq coll)]
    (f (first s)
       (reduce_ f zero (rest s)))
    zero))

(ann append_ (All [a b] [(Seqable a) (Seqable b) -> (U (Seqable (U a b))
                                                       (ASeq (U a b)))]))
(defn append_
  [coll1 coll2]
  (reduce_ cons coll2 coll1))


; -------- main

; if you comment out this function, you will get :ok
(ann map-1 (All [a b] [[a -> b] (Seqable a)
                       -> (LazySeq b)]))
(defn map-1 [f coll]
  (lazy-seq
   (if-let [s (seq coll)]
     (cons (f (first s))
           (map-1 f (rest s))))))

(ann map-2 (All [a b] [[a -> b] (Seqable a) -> (LazySeq b)]))
(defn map-2
  [f coll]
  (lazy-seq
   (reduce_ (fn> [x :- a ; ERROR!! -- Cannot resolve type: a
                  y :- (Seqable b)]
              (append_ [(f x)] y))
            []
            coll)))

Activity

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: