<< Back to previous view

[CTYP-60] HMap :optional fields behaving oddly, hole in the type system Created: 14/Sep/13  Updated: 25/Sep/13  Resolved: 15/Sep/13

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

Type: Defect Priority: Major
Reporter: Chris Spencer Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

user=> (cf {:a "a"} (HMap :optional {:a Number}))
(U (HMap :mandatory {} :absent-keys #{:a}) (HMap :mandatory {:a Number}))

I would expect this to fail to type, and it points out the following hole in the type system:

(ann odd-type [-> (U (HMap :mandatory {} :absent-keys #{:a})
(HMap :mandatory {:a Number}))])
(defn odd-type [] {:a "a"})

(ann wrong-type [-> (HMap :mandatory {:a Number})])
(defn wrong-type []
(let [a (odd-type)]
(assert (get a :a))
(print-env "my-types")
a))

print-env:
{:env {a (HMap :mandatory {:a java.lang.Number})}, :props ((is (U java.lang.Number nil) a [(Key :a)]))}



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:44 AM ]

Fixed: https://github.com/clojure/core.typed/commit/0e6d4c4d358a55539b569c51935033646044d6dd

Please verify with: [org.clojure/core.typed "0.2.6-20130915.134318-3"]

Comment by Ambrose Bonnaire-Sergeant [ 15/Sep/13 8:56 AM ]

Verified via IRC.

Generated at Wed Oct 22 21:45:10 CDT 2014 using JIRA 4.4#649-r158309.