<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged :req!</title>
<link>https://ask.clojure.org/index.php/tag/%3Areq%21</link>
<description>Powered by Question2Answer</description>
<item>
<title>:req! on a nested map with :missing binds an internal Object</title>
<link>https://ask.clojure.org/index.php/15274/req-on-a-nested-map-with-missing-binds-an-internal-object</link>
<description>&lt;pre&gt;&lt;code&gt;(let [{:keys!   [card]
       :missing m} {}]
  [card m])
;; =&amp;gt; [nil {:card nil}]

(let [{:req!    {{:as c} :card}
       :missing m} {}]
  [c m])
;; =&amp;gt; [#object[java.lang.Object 0x...] nil]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The input has no &lt;code&gt;:card&lt;/code&gt;, but &lt;code&gt;:card&lt;/code&gt; is required. Expected &lt;code&gt;[nil {:card nil}]&lt;/code&gt;, as for &lt;code&gt;:keys!&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;Instead:&lt;br&gt;
1. &lt;code&gt;m&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;, so the missing key is not reported.&lt;br&gt;
2. &lt;code&gt;c&lt;/code&gt; is bound to an internal &quot;not found&quot; object that should not leave Clojure&#039;s code.&lt;br&gt;
3. &lt;code&gt;:select&lt;/code&gt; returns data that was never in the input:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    (def select-card
      (selector {:req!    {{:keys [a]} :card}
                 :missing m
                 :select  s}))

    (select-card {})
    ;; =&amp;gt; {:select {:card {}}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With a more usual nested form, the object is hidden and the bug is silent:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [{:req!    {{:keys [number]} :card}
       :missing m} {}]
  [number m])
;; =&amp;gt; [nil nil]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;number&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt; and looks normal, but &lt;code&gt;:card&lt;/code&gt; is still not reported as missing.&lt;/p&gt;
&lt;p&gt;It looks like for a simple name the not-found marker is checked, recorded as missing, and replaced with &lt;code&gt;nil&lt;/code&gt;. &lt;br&gt;
For a nested form that check is skipped, and the marker is passed into the nested form.&lt;/p&gt;
&lt;p&gt;Without &lt;code&gt;:missing&lt;/code&gt;, it throws &lt;code&gt;Missing required key: :card&lt;/code&gt;, as expected.&lt;/p&gt;
&lt;p&gt;Reproduced on Clojure 1.13.0-alpha10.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15274/req-on-a-nested-map-with-missing-binds-an-internal-object</guid>
<pubDate>Sun, 25 Oct 2026 20:10:39 +0000</pubDate>
</item>
</channel>
</rss>