<< Back to previous view

[CTYP-136] annotation for last does not leverage non-empty collections Created: 04/May/14  Updated: 31/May/14  Resolved: 31/May/14

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

Type: Enhancement Priority: Trivial
Reporter: Jake Goulding Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None

Attachments: File non-empty-last.diff    


I expected this to be all right:

(ann foo [(t/Coll t/AnyInteger) -> (U (Value :empty) t/AnyInteger)])
(defn foo [c]
  (if (seq c)
    (last c)

But I get this error:

Expected:       (U Long Integer BigInteger BigInt Byte Short (Value :empty))
Actual:         (U Long Integer BigInteger BigInt Byte Short (Value :empty) nil)

Reannotating last as this causes it to work:

(ann clojure.core/last
  (All [x]
        [(t/NonEmptySeqable x) -> x]
        [(t/Option (t/Seqable x)) -> (U nil x)])))

Comment by Ambrose Bonnaire-Sergeant [ 31/May/14 12:51 PM ]


Generated at Wed Jan 17 07:40:17 CST 2018 using JIRA 4.4#649-r158309.