ClojureScript

`case` doesn't match quoted symbols

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    ClojureScript

Description

It works fine in the Clojure 1.4.0 REPL:

user=> (let [a 'a] (case a nil :nil '& :amp :none))
:none
user=> (let [a '&] (case a nil :nil '& :amp :none))
:amp
user=> (let [a 'b] (case a nil :nil 'b :b :none))
:b

But in the CLJS Rhino REPL this is what I see:

ClojureScript:cljs.user> (let [a 'a] (case a nil :nil '& :amp :none))
:none
ClojureScript:cljs.user> (let [a '&] (case a nil :nil '& :amp :none))
:none
ClojureScript:cljs.user> (let [a 'b] (case a nil :nil 'b :b :none))
:none

Activity

Hide
David Nolen added a comment -

This did reveal a bug though the ticket description does have a user error. The tests for case can only be literals - you should not quote the test values. For example the following is how symbols should be tested:

(let [a '&] (case a nil :nil & :amp :none))

The above code that quotes the test is actually equivalent to:

(let [a '&] (case a nil :nil (quote &) :amp :none))

Which happens to work but probably isn't intended.

With the coming patch CLJS now works as Clojure.

Show
David Nolen added a comment - This did reveal a bug though the ticket description does have a user error. The tests for case can only be literals - you should not quote the test values. For example the following is how symbols should be tested:
(let [a '&] (case a nil :nil & :amp :none))
The above code that quotes the test is actually equivalent to:
(let [a '&] (case a nil :nil (quote &) :amp :none))
Which happens to work but probably isn't intended. With the coming patch CLJS now works as Clojure.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: