<< Back to previous view

[CTYP-97] 0.2.16 seems to introduce a bug Created: 14/Nov/13  Updated: 20/Jul/14  Resolved: 20/Jul/14

Status: Closed
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: kshramt Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

core.typed 0.2.16 and later


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]
                             (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)))

(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]
   (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]
   (reduce_ (fn> [x :- a ; ERROR!! -- Cannot resolve type: a
                  y :- (Seqable b)]
              (append_ [(f x)] y))

Comment by Ambrose Bonnaire-Sergeant [ 14/Nov/13 7:58 PM ]

Ah, that's not surprising. I overhauled the scoping for type variables, forgot this case.

Thanks for the report.

Comment by vladimir [ 18/Mar/14 12:55 PM ]


still got the same on 0.2.38.. is it closed because fixed?



Comment by Ambrose Bonnaire-Sergeant [ 18/Mar/14 1:18 PM ]

Added passing test for CTYP-97 https://github.com/clojure/core.typed/commit/614244afc482826b650e0ebd14892f0ebbc411a0

Comment by Ambrose Bonnaire-Sergeant [ 18/Mar/14 1:19 PM ]


Please elaborate on your issue.


Generated at Mon Oct 24 04:00:15 CDT 2016 using JIRA 4.4#649-r158309.