core.typed

"Cannot assoc args" with HMap intersections

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Blocker Blocker
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    [org.clojure/core.typed "0.2.53"]

Description

=> (t/cf (assoc (t/ann-form {:foo 1, :bar 2}
                            (t/HMap :mandatory {:foo Number
                                                :bar Number}))
                :baz 3))
[(t/HMap :mandatory {:baz (t/Value 3), :foo java.lang.Number, :bar java.lang.Number}) {:then tt, :else ff}]

=> (t/cf (assoc (t/ann-form {:foo 1, :bar 2}
                            (t/I (t/HMap :mandatory {:foo Number})
                                 (t/HMap :mandatory {:bar Number})))
                :baz 3))
Type Error (/private/var/folders/x2/47j5hlbs01b9b4mjz_8fyf05m8hy4p/T/form-init2093510643541319345.clj:1:7) Cannot assoc args `[(clojure.core.typed/Value :baz) {:then tt, :else ff}] [(clojure.core.typed/Value 3) {:then tt, :else ff}]` on (clojure.core.typed/I (clojure.core.typed/HMap :mandatory {:foo java.lang.Number}) (clojure.core.typed/HMap :mandatory {:bar java.lang.Number}))
ExceptionInfo Type Checker: Found 1 error  clojure.core/ex-info (core.clj:4327)

Activity

Hide
Timo Mihaljov added a comment - - edited

As a workaround, assoc can be replaced with assoc-in. It loses the type and returns Any, but the type can be recovered with an assertion or a postcondition (e.g. {:post [((t/pred MyMap) %)]}).

Show
Timo Mihaljov added a comment - - edited As a workaround, assoc can be replaced with assoc-in. It loses the type and returns Any, but the type can be recovered with an assertion or a postcondition (e.g. {:post [((t/pred MyMap) %)]}).
Ambrose Bonnaire-Sergeant made changes -
Field Original Value New Value
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: