core.typed

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

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: 0.2.0
  • 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_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn11331$fn11332$fn_11333.invoke(cs_gen.clj:864)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn11331$fn_11332.invoke(cs_gen.clj:863)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$fn11330$fn_11331.invoke(cs_gen.clj:861)
at clojure.core.typed.cs_gen$any_impl_RBRACK_11316$iter_1131711321$fn11322$fn11323$fn11324$iter1132511329$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: