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

select-keys on HMap returns Map with union key and value types

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: Backlog
    • Components: None
    • Labels:
      None
    • Environment:

      core.typed 0.2.40

      Description

      Currently select-keys on an HMap returns a Map with unions for keys and values.

      => (t/cf {:foo 1, :bar "2", :baz \3})
      [(HMap :mandatory {:baz (Value \3), :bar (Value "2"), :foo (Value 1)} :complete? true) {:then tt, :else ff}]
      
      => (t/cf (select-keys {:foo 1, :bar "2", :baz \3}
                            [:foo :bar]))
      (t/Map (U (Value :baz) (Value :foo) (Value :bar)) (U (Value 1) (Value \3) (Value "2")))
      

      This results in type errors when select-keys is used to remove extra keys from an HMap.

      Expected behaviour: select-keys should return an HMap with a subset of the :mandatory keys of its input HMap.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              noidi Timo Mihaljov
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: