core.typed

java.lang.AssertionError: Assert failed: (<= (count s) cnt)

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 0.2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    OSX

Description

With core.typed 0.2.50 I get this exception:

Exception in thread "main" java.lang.AssertionError: Assert failed: (<= (count s) cnt)
        at clojure.core.typed.cs_gen$pad_right.invokePrim(cs_gen.clj:1252)
        at clojure.core.typed.cs_gen$cs_gen_Function.invoke(cs_gen.clj:1296)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331$fn__11332$fn__11333.invoke(cs_gen.clj:864)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331$fn__11332.invoke(cs_gen.clj:863)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330$fn__11331.invoke(cs_gen.clj:861)
        at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter__11317__11321$fn__11322$fn__11323$fn__11324$iter__11325__11329$fn__11330.invoke(cs_gen.clj:861)
...

When type-checking this code (either from lein typed (0.3.4) or the Emacs plugin):

(ns demo
  (:require [clojure.core.typed :refer [ann Seq Option]]))

(ann distinct-except
  (All [x]
       [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
(defn distinct-except
  "Same as distinct, but keeps duplicates if they pass exception?"
  [exception? [head & tail :as coll]]
  (lazy-seq
   (when head
     (cons head
           (distinct-except exception?
                            (if (exception? head)
                              tail
                              (remove (partial = head) tail)))))))

I get the same exception if I just (cf ...) the defn too. I've attached the full stacktrace. Let me know if there's anything else I can helpfully supply.

Activity

Hide
Kris Jenkins added a comment -

Oh, sorry - Jira code formatting. Here's that code again:

Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns demo
  (:require [clojure.core.typed :refer [ann Seq Option]]))

(ann distinct-except
  (All [x]
       [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
(defn distinct-except
  "Same as distinct, but keeps duplicates if they pass exception?"
  [exception? [head & tail :as coll]]
  (lazy-seq
   (when head
     (cons head
           (distinct-except exception?
                            (if (exception? head)
                              tail
                              (remove (partial = head) tail)))))))
Show
Kris Jenkins added a comment - Oh, sorry - Jira code formatting. Here's that code again:
Unable to find source-code formatter for language: clojure. Available languages are: javascript, sql, xhtml, actionscript, none, html, xml, java
(ns demo
  (:require [clojure.core.typed :refer [ann Seq Option]]))

(ann distinct-except
  (All [x]
       [[x -> Boolean] (Option (Seq x)) -> (Option (Seq x))]))
(defn distinct-except
  "Same as distinct, but keeps duplicates if they pass exception?"
  [exception? [head & tail :as coll]]
  (lazy-seq
   (when head
     (cons head
           (distinct-except exception?
                            (if (exception? head)
                              tail
                              (remove (partial = head) tail)))))))

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: