conditional reading bugs

Description

Bugs in conditional reading:

(ns bug) #?(:cljs {'a 1 'b 2}) #?(:cljs (let [{{b :b} :a {d :d} :c} {}]))

Requiring / loading this file at the REPL results in the following exception:

CompilerException java.lang.IllegalArgumentException: Duplicate key: null, compiling: clojure.lang.Compiler.load (Compiler.java:7244) clojure.lang.RT.loadResourceScript (RT.java:371) clojure.lang.RT.loadResourceScript (RT.java:362) clojure.lang.RT.load (RT.java:446) clojure.lang.RT.load (RT.java:412) clojure.core/load/fn--5427 (core.clj:5862) clojure.core/load (core.clj:5861) clojure.core/load-one (core.clj:5667) clojure.core/load-lib/fn--5376 (core.clj:5707) clojure.core/load-lib (core.clj:5706) clojure.core/apply (core.clj:630) clojure.core/load-libs (core.clj:5745) Caused by: IllegalArgumentException Duplicate key: null clojure.lang.PersistentArrayMap.createWithCheck (PersistentArrayMap.java:70) clojure.lang.RT.map (RT.java:1537) clojure.lang.LispReader$MapReader.invoke (LispReader.java:1152) clojure.lang.LispReader.read (LispReader.java:255) clojure.lang.LispReader.access$800 (LispReader.java:40) clojure.lang.LispReader$ConditionalReader.readCondDelimited (LispReader.java:1376) clojure.lang.LispReader$ConditionalReader.invoke (LispReader.java:1448) clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:684) clojure.lang.LispReader.read (LispReader.java:255) clojure.lang.LispReader.readDelimitedList (LispReader.java:1191) clojure.lang.LispReader$ListReader.invoke (LispReader.java:1040) clojure.lang.LispReader.read (LispReader.java:255)
(ns bug) (def m #?(:cljs ^{:a :b} {} :clj ^{:a :b} {}))
CompilerException java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map, compiling:(bug.cljc:3:25) clojure.lang.Compiler.load (Compiler.java:7244) clojure.lang.RT.loadResourceScript (RT.java:371) clojure.lang.RT.loadResourceScript (RT.java:362) clojure.lang.RT.load (RT.java:446) clojure.lang.RT.load (RT.java:412) clojure.core/load/fn--5427 (core.clj:5862) clojure.core/load (core.clj:5861) clojure.core/load-one (core.clj:5667) clojure.core/load-lib/fn--5376 (core.clj:5707) clojure.core/load-lib (core.clj:5706) clojure.core/apply (core.clj:630) clojure.core/load-libs (core.clj:5745) Caused by: IllegalArgumentException Metadata must be Symbol,Keyword,String or Map clojure.lang.LispReader$MetaReader.invoke (LispReader.java:790) clojure.lang.LispReader.read (LispReader.java:255) clojure.lang.LispReader.access$800 (LispReader.java:40) clojure.lang.LispReader$ConditionalReader.readCondDelimited (LispReader.java:1376) clojure.lang.LispReader$ConditionalReader.invoke (LispReader.java:1448) clojure.lang.LispReader$DispatchReader.invoke (LispReader.java:684) clojure.lang.LispReader.read (LispReader.java:255) clojure.lang.LispReader.readDelimitedList (LispReader.java:1191) clojure.lang.LispReader$ListReader.invoke (LispReader.java:1040) clojure.lang.LispReader.read (LispReader.java:255) clojure.lang.LispReader.read (LispReader.java:195) clojure.lang.Compiler.load (Compiler.java:7232)
(ns bug) #?(:cljs {:a #_:b :c})
CompilerException java.lang.RuntimeException: Map literal must contain an even number of forms

Cause: Not properly handling suppress-read flag.

Patch: 0001-CLJ-1698-fix-conditional-reading-bugs.patch

Environment

None

Attachments

1
  • 20 Apr 2015, 05:56 PM

Activity

Show:

Alex Miller April 11, 2015 at 11:49 AM

For Clojure REPL repro:

(def opts {:features #{:clj} :read-cond :allow}) (read-string opts "#?(:cljs {'a 1 'b 2})") (read-string opts "#?(:cljs (let [{{b :b} :a {d :d} :c} {}]))") (read-string opts "(def m #?(:cljs ^{:a :b} {} :clj ^{:a :b} {}))") (read-string opts "(def m #?(:cljs ^{:a :b} {} :clj ^{:a :b} {}))") (read-string opts "#?(:cljs {:a #_:b :c}")
Completed

Details

Assignee

Reporter

Labels

Approval

Ok

Patch

Code and Test

Priority

Affects versions

Fix versions

Created April 10, 2015 at 10:17 PM
Updated April 24, 2015 at 4:14 PM
Resolved April 24, 2015 at 4:14 PM