<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged possible bug</title>
<link>https://ask.clojure.org/index.php/tag/possible+bug</link>
<description></description>
<item>
<title>Possible bug in conditional with NaN comparison</title>
<link>https://ask.clojure.org/index.php/15174/possible-bug-in-conditional-with-nan-comparison</link>
<description>&lt;p&gt;I encountered this possible bug while running a property-based test suite in a ClojureCLR project. Given a comparison between NaN in an if expression, it seemingly takes the wrong branch. &lt;/p&gt;
&lt;p&gt;Clojure (CLR)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;λ cljr
Clojure core loaded in 837 milliseconds.
Starting main
Clojure core loaded in 409 milliseconds.
Clojure 1.12.2
user=&amp;gt; (&amp;lt;= ##NaN ##NaN)
false
user=&amp;gt; (if (&amp;lt;= ##NaN ##NaN) true false)
true
user=&amp;gt; (let [t (&amp;lt;= ##NaN ##NaN)] (if t true false))
false

user=&amp;gt; (&amp;gt;= ##NaN ##NaN)
false
user=&amp;gt; (if (&amp;gt;= ##NaN ##NaN) true false)
true
user=&amp;gt; (let [t (&amp;gt;= ##NaN ##NaN)] (if t true false))
false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I wasn't able to replicate the issue on Clojure (JVM), C#, or F#.&lt;/p&gt;
&lt;p&gt;Clojure (JVM)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;λ clj
Clojure 1.12.0
user=&amp;gt; (&amp;lt;= ##NaN ##NaN)
false
user=&amp;gt; (if (&amp;lt;= ##NaN ##NaN) true false)
false
user=&amp;gt; (let [t (&amp;lt;= ##NaN ##NaN)] (if t true false))
false
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C#&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;using System;
					
public class Program
{
	public static void Main()
	{
		Console.WriteLine(Double.NaN &amp;lt;= Double.NaN);
		if (Double.NaN &amp;lt;= Double.NaN) {
			Console.WriteLine(true);
		} else {
			Console.WriteLine(false);
		}
		var t = Double.NaN &amp;lt;= Double.NaN;
		if (t) {
			Console.WriteLine(true);
		} else {
			Console.WriteLine(false);
		}
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;False&lt;br&gt;
False&lt;br&gt;
False&lt;/p&gt;
&lt;p&gt;F#&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;λ dotnet fsi

&amp;gt; nan &amp;lt;= nan;;                                                                
val it: bool = false

&amp;gt; if (nan &amp;lt;= nan) then true else false;;                          
val it: bool = false

&amp;gt; let t = nan &amp;lt;= nan;;
val t: bool = false

&amp;gt; if t then true else false;;
val it: bool = false
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>ClojureCLR</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15174/possible-bug-in-conditional-with-nan-comparison</guid>
<pubDate>Sat, 11 Jul 2026 15:01:23 +0000</pubDate>
</item>
<item>
<title>Syntax-quoted lists can return nil, differs from ClojureScript</title>
<link>https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</link>
<description>&lt;p&gt;Syntax quoted lists can return &lt;code&gt;nil&lt;/code&gt; if only empty seqables are spliced into it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `(~@[])
nil
user=&amp;gt; `(~@[] ~@[])
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the implementation then ensures syntax-quoted empty lists are not nil:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `()
()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ClojureScript returns an empty list in these cases:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;`(~@[])
=&amp;gt; ()
`(~@[] ~@[])
=&amp;gt; ()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The expansion of syntax quote itself is not necessarily a problem if it differs between platforms, but here the evaluation of the expansion differs. This can cause macros to behave differently between platforms (e.g., JVM Clojure vs bootstrapped cljs).&lt;/p&gt;
&lt;p&gt;This behavior seems to be present with all versions of Clojure &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/f85444e6f890eb585e598efefdbd84727427e0a4/src/jvm/clojure/lang/LispReader.java#L731&quot;&gt;including 1.0.0&lt;/a&gt;, so perhaps the ship has sailed here. I went searching for an existing issue or documentation and AFAICT only &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1425&quot;&gt;CLJ-1425&lt;/a&gt; mentions this oddity.&lt;/p&gt;
&lt;p&gt;The reference docs for &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#syntax-quote&quot;&gt;Syntax Quote&lt;/a&gt; also seem to contradict this behavior:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;For Lists/Vectors/Sets/Maps, syntax-quote establishes a template of the corresponding data structure.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</guid>
<pubDate>Sun, 28 Jun 2026 20:43:55 +0000</pubDate>
</item>
<item>
<title>Is it valid for metadata to have metadata?</title>
<link>https://ask.clojure.org/index.php/14927/is-it-valid-for-metadata-to-have-metadata</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am implementing a pretty printer and while adding/testing support for &lt;code&gt;*print-meta*&lt;/code&gt; I noticed that &lt;code&gt;pr&lt;/code&gt; prints an object whose metadata has metadata in the following way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (binding [*print-meta* true]
        (pr-str (with-meta 'foo (with-meta {:bar :baz} {:frob :zork}))))
&quot;^^{:frob :zork} {:bar :baz} foo&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When reading such a form, only the &quot;outermost&quot; metadata is preserved:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (binding [*print-meta* true]
        (let [s (pr-str (with-meta 'foo (with-meta {:bar :baz} {:frob :zork})))
              o (clojure.edn/read-string s)]
          {:o o
           :meta (meta o)
           :metameta (meta (meta o))}))
{:o foo, :meta {:bar :baz}, :metameta nil}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The behaviour is the same for &lt;code&gt;clojure.core/read-string&lt;/code&gt; and also the &lt;code&gt;tools.reader&lt;/code&gt; readers.&lt;/p&gt;
&lt;p&gt;Can anyone clarify for me if this is either:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;simply GIGO&lt;/li&gt;
&lt;li&gt;a bug in the printer&lt;/li&gt;
&lt;li&gt;a bug in the readers&lt;/li&gt;
&lt;li&gt;a state that should be somehow disallowed&lt;/li&gt;
&lt;li&gt;something else?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Neither the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/metadata&quot;&gt;metadata reference&lt;/a&gt; nor the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#metadata&quot;&gt;reader reference&lt;/a&gt; explicitly allow or disallow such a thing, as far as I can tell. Should they?&lt;/p&gt;
&lt;p&gt;N.B. this is not an issue in any kind of production context and I'm not aware of any library or program that constructs such a thing. It's simply something I tested to see if/how it would break the pretty printer I'm building.&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;I dug into this some more with Nicola. Here's a perhaps much clearer case that demonstrates the reader isn't propagating nested metadata:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (let [o ^^:foo {1 2} {3 4}]
        {:o o :meta (meta o) :metameta (meta (meta o))})
{:o {3 4}, :meta {1 2}, :metameta nil}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;:metameta&lt;/code&gt; should be &lt;code&gt;{:foo true}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L979-L982&quot;&gt;this section of MetaReader.invoke&lt;/a&gt; we are iterating over the entries of the meta map and manually associng them into the existing meta of the object; any metadata on the meta map itself is not preserved. I have a patch that adds a failing test case and correctly propagates the the meta map's metadata. If this is worth a ticket then I'm more than happy to attach it to that or send it to you directly.&lt;/p&gt;
</description>
<category>Metadata</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14927/is-it-valid-for-metadata-to-have-metadata</guid>
<pubDate>Thu, 12 Feb 2026 15:45:20 +0000</pubDate>
</item>
<item>
<title>Possible ClojureScript bug: corner case with regex literal compilation</title>
<link>https://ask.clojure.org/index.php/14717/possible-clojurescript-corner-regex-literal-compilation</link>
<description>&lt;p&gt;I've found what I believe to be a bug in ClojureScript regarding compilation of certain regex literals to JavaScript, a specific example being &lt;code&gt;#&quot;(?i)&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In some cases, &lt;code&gt;#&quot;(?i)&quot;&lt;/code&gt; will be compiled to the JavaScript syntax &lt;code&gt;//i&lt;/code&gt;, which is in fact &lt;em&gt;not&lt;/em&gt; a JavaScript regex literal, but rather a JavaScript single line comment.  This then comments out all remaining code on the same generated line, resulting in a syntax error when the code is run on a JavaScript runtime.&lt;/p&gt;
&lt;p&gt;This minimal unit test example demonstrates the issue:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(ns regex-test&lt;/code&gt;&lt;br&gt;
&lt;code&gt;  (:require [cljs.test :refer-macros [deftest testing is]]))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(deftest failing-test&lt;/code&gt;&lt;br&gt;
&lt;code&gt;  (testing &quot;Minimal reproduction&quot;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;    (is (not (nil? #&quot;(?i)&quot;)))))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;As a side note, it's worth mentioning that &lt;code&gt;(?i)&lt;/code&gt; is not a valid native JavaScript regex in the first place, so I assume ClojureScript is trying to emulate compatibility with JVM regexes (where this is valid), and converting it to the nearest valid JS equivalent - either &lt;code&gt;(?i:)&lt;/code&gt; (e.g. at the REPL), or &lt;code&gt;//i&lt;/code&gt; (in compiled code, but which is syntactically not a JS regex literal at all).&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14717/possible-clojurescript-corner-regex-literal-compilation</guid>
<pubDate>Sun, 21 Sep 2025 02:59:22 +0000</pubDate>
</item>
</channel>
</rss>