Filtering with an instantiated identity function doesn't guarantee removal of nil

Description

The following doesn't pass type check:

{{(:require [clojure.core.typed] :as t)
(t/ann filter-that [(t/Seqable (t/U nil Number)) -> (t/Seqable Number)])
(defn filter-that [coll]
(filter (t/inst identity (t/U nil Number)) coll))}}

I would expect the return type of the function to be a collection without the nil type. The error I receive:

Polymorphic function filter could not be applied to arguments:
Polymorphic Variables:
x
y

Domains:
[x -> t/Any] (t/Option (Seqable x))

Arguments:
[(t/U nil Number) -> (t/U nil Number) :filters {:then (! (t/U nil false) 0), :else (is (t/U nil false) 0)} :object {:id 0}] (Seqable (t/U nil Number))

Ranges:
(t/ASeq x)

with expected type:
(t/Seqable Number)

in: (filter (clojure.core.typed/inst-poly identity (quote (#))) coll)

Environment

core.typed 0.3.7, clojure 1.7

Activity

Show:
Ambrose Bonnaire-Sergeant
July 17, 2015, 3:49 PM

The current workaround for this is to filter on a function with a positive `then` proposition.

eg. (filter number? coll)

Ambrose Bonnaire-Sergeant
July 17, 2015, 5:01 PM

Changing to enhancement, as current behaviour is not unsound.

Ambrose Bonnaire-Sergeant
December 3, 2017, 10:40 PM

Huge job.

Declined

Assignee

Ambrose Bonnaire-Sergeant

Reporter

import

Labels

None

Approval

None

Patch

None

Affects versions

Priority

Minor
Configure