<< Back to previous view

[CTYP-83] check-ns takes exponentially longer on each invocation Created: 04/Oct/13  Updated: 01/Sep/14  Resolved: 01/Sep/14

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

Type: Defect Priority: Blocker
Reporter: Hugo Duncan Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Running `(check-ns pathological)` repeatedly on the following namespace, `check-ns` takes longer and longer to complete.

(ns pathological
  (:require
   [clojure.core.typed :refer [ann def-alias loop>
                               NonEmptyVec NilableNonEmptySeq]]))

(def-alias VersionVector (NonEmptyVec Number))
(ann version-less [(U nil VersionVector) (U nil VersionVector) -> boolean])
(defn version-less
  "Compare two version vectors."
  [v1 v2]
  (loop> [v1 :- (NilableNonEmptySeq Number) (seq v1)
          v2 :- (NilableNonEmptySeq Number) (seq v2)]
    (let [fv1 (first v1)
          fv2 (first v2)]
      (cond
       (and (not v1) (not v2)) false
       (and v1 (not v2)) false
       (or (and (not v1) v2)
           (and fv1 fv2 (< fv1 fv2))) true
           (and fv1 fv2 (> fv1 fv2)) false
           :else (recur (next v1) (next v2))))))


 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 01/Sep/14 3:41 PM ]

Fix will be included in 0.2.68 https://github.com/clojure/core.typed/commit/0065e05fa20c3c33dea49937558af0933c363125





[CTYP-173] (first (filter ...)) type checks in Clojure, not ClojureScript Created: 30/Aug/14  Updated: 30/Aug/14

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

Type: Defect Priority: Major
Reporter: Kris Jenkins Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: None
Environment:

[[org.clojure/clojure "1.6.0"]
[org.clojure/core.typed "0.2.67"]
[org.clojure/clojurescript "0.0-2322"]]



 Description   

This code type check in Clojure:

Unable to find source-code formatter for language: clj. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ann ffilter
  (All [a]
       [[a -> Any] (Option (Seqable a)) -> (Option a)]))

(defn ffilter
  [pred coll]
  (first (filter pred coll)))

But fails under ClojureScript with:

Type Error (typed-playground.clojurescript:26:3) Polymorphic function cljs.core/first could not be applied to arguments:
Polymorphic Variables:
x

Domains:
(clojure.core.typed/HSequential [x clojure.core.typed/Any *])
(cljs.core.typed/Option (cljs.core.typed/EmptySeqable x))
(cljs.core.typed/NonEmptySeqable x)
(cljs.core.typed/Option (cljs.core.typed/Seqable x))

Arguments:
(cljs.core/ASeq a)

Ranges:
x :object {:path [(Nth 0)], :id 0}
nil
x
(cljs.core.typed/Option x)

with expected type:
(cljs.core.typed/Option a)

in: (cljs.core/first (cljs.core/filter pred coll))
in: (cljs.core/first (cljs.core/filter pred coll))






Generated at Tue Sep 02 19:11:01 CDT 2014 using JIRA 4.4#649-r158309.