jasongilman / proto-repl

A Clojure Development Environment package for the Atom editor
https://atom.io/packages/proto-repl
MIT License
565 stars 50 forks source link

REPL displays namespace-qualified hash maps without their namespace #243

Closed seancorfield closed 3 years ago

seancorfield commented 7 years ago

Evaluate the following in ProtoREPL (in any Clojure REPL):

{:a/b 1}

Expected (Clojure 1.9):

#:a{:b 1}

Actual (Clojure 1.9):

{:b 1}

The namespace qualifier just disappears.

naartjie commented 7 years ago

Is it an issue with the underlying eval runtime, which would mean this is related to issues with output of maps with ordered keys #192?

jasongilman commented 7 years ago

The result returned by nREPL is #:a{:b 1}. Proto REPL uses ClojureScript for some of the parsing code that runs in Atom. It seems like ClojureScript isn't parsing that into the same value. If I run (pr-str (cljs.reader/read-string "#:a{:b 1}")) it returns {:b 1}.

I think that this is caused by http://dev.clojure.org/jira/browse/CLJS-1706. Until that is fixed it's going to be difficult to fix this completely. That said I have put in a work around so that the original string returned from the REPL will be used for display.

seancorfield commented 7 years ago

Wow, I'm kinda shocked that ClojureScript is so far behind on the namespaced-maps stuff, given all the work that's been done porting clojure.spec across!

seancorfield commented 7 years ago

That update is a slight improvement, but only for inline evaluation:

Inline eval of {:c/d 1} shows namespace prefix

REPL evaluation of {:a/b 1} does not

Is that expected with that update? Is there no way to display the actual result from nREPL?

jasongilman commented 7 years ago

Do you have pretty printing turned on? If you turn it off you'll see the correct value. The auto pretty printing is using ClojureScript and Fipp so it will have the same problem.

seancorfield commented 7 years ago

Ah yes, that did indeed fix it. What side effects will I get from disabling that?

jasongilman commented 7 years ago

You won't get automatically pretty printed results at the REPL. This is actually the setting that I use. You can still pretty print the results by sending the pretty print command after executing something. That will pretty print correctly because it uses clojure.pprint/pp through the REPL. See the keybinding documentation for the keystroke.

On Apr 16, 2017, at 1:41 AM, Sean Corfield notifications@github.com wrote:

Ah yes, that did indeed fix it. What side effects will I get from disabling that?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.