This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-08
Channels
- # announcements (2)
- # asami (2)
- # babashka (7)
- # beginners (59)
- # cider (12)
- # cljdoc (1)
- # cljs-dev (18)
- # clojure (23)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojured (16)
- # clojurescript (22)
- # core-typed (8)
- # cursive (3)
- # datomic (24)
- # events (2)
- # fulcro (4)
- # gratitude (1)
- # helix (13)
- # hoplon (18)
- # integrant (2)
- # introduce-yourself (1)
- # jobs-discuss (1)
- # joyride (5)
- # minecraft (1)
- # off-topic (76)
- # pathom (18)
- # podcasts-discuss (8)
- # polylith (11)
- # remote-jobs (4)
- # rewrite-clj (22)
- # sci (4)
- # shadow-cljs (152)
- # sql (4)
- # tools-build (26)
- # tools-deps (34)
Hi! I don’t understand this error:
Type mismatch:
Expected: (t/U Short Byte Long BigInt BigInteger Integer)
Actual: (t/I t/AnyInteger t/Num)
in:
(:pokemon/level pokemon 1)
Occur with this code:
^::t/ignore
(def PokemonLevel
[:and :int [:>= 1] [:<= 100]])
^::t/ignore
(def Pokemon
[:map
[:pokemon/name :string]
[:pokemon/level {:optional true} PokemonLevel])
(m/=> get-pokemon-level [:=> [:cat Pokemon] PokemonLevel])
(defn get-pokemon-level [pokemon]
(:pokemon/level pokemon 1))
I don’t understand why I get a different type.Looks like Pokemon
translates to a strange type
(t/HMap :mandatory {:pokemon/name t/Str} :optional {:pokemon/level (t/I t/AnyInteger t/Num)})
BTW I'm using metadata to debug this, might help you in the future:
(defn get-pokemon-level [pokemon]
^::t/dbg
(:pokemon/level ^::t/dbg pokemon 1))
;=::t/dbg id=G__54475 (:pokemon/level pokemon 1)
;=::t/dbg id=G__54475 expected: (t/U Short Byte Long BigInt BigInteger Integer)
;= ::t/dbg id=G__54476 pokemon
;= ::t/dbg id=G__54476 result: [(t/HMap :mandatory {:pokemon/name t/Str} :optional {:pokemon/level (t/I t/AnyInteger t/Num)}) {:then tt, :else ff} {:id pokemon__#0}]
;=::t/dbg id=G__54475 result: (t/U Short Byte Long BigInt BigInteger Integer)
Minimal:
^::t/ignore
(def PokemonLevel
[:and :int [:>= 1] [:<= 100]])
(m/=> get-pokemon-level [:=> [:cat [:maybe PokemonLevel]] PokemonLevel])
(defn get-pokemon-level [pokemon-level]
(or pokemon-level 1))
Type mismatch:
Expected: (t/U Short Byte Long BigInt BigInteger Integer)
Actual: (t/I t/AnyInteger t/Num)
in:
or__5581__auto__
@UHZPYLPU1 releasing 1.0.31
which should work around this problem. now [:and A B]
will be simplified to A
instead of (t/I A B)
.
Thanks @U055XFK8V