Uploaded image for project: 'core.typed'
  1. CTYP-72

merge doesn't seem to like records

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: 0.3.0, 0.2
    • Fix versions: Backlog
    • Components: Core type system
    • Labels:
      None

      Description

      I'm pretty sure this should pass

      (ns moonrise
        (:require [clojure.core.typed :refer :all]))
      
      (ann-record X [a :- Number])
      (defrecord X [a])
      
      (ann x X)
      (def x (merge (X. 3) {:z 4}))
      

      but it gives

      Type Error (moonrise:8:8) Polymorphic function clojure.core/merge could not be applied to arguments:
      Polymorphic Variables:
      	k
      	v
      
      Domains:
      	nil *
      	(clojure.lang.IPersistentMap k v) (clojure.lang.IPersistentMap k v) *
      	(Option (clojure.lang.IPersistentMap k v)) *
      
      Arguments:
      	moonrise.X (HMap :mandatory {:z (Value 4)} :complete? true)
      
      Ranges:
      	nil
      	(clojure.lang.IPersistentMap k v)
      	(Option (clojure.lang.IPersistentMap k v))
      
      with expected type:
      	moonrise.X
      
      in: (clojure.core/merge (new moonrise.X 3) (quote {:z 4}))
      in: (def x (clojure.core/merge (new moonrise.X 3) (quote {:z 4})))
      
      
      Type Checker: Found 1 error
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              alex+import import
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: