Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace map should allow all Clojure whitespace between prefix and map #140

Closed
lread opened this issue Mar 16, 2021 · 2 comments
Closed
Labels
Projects

Comments

@lread
Copy link
Collaborator

lread commented Mar 16, 2021

Version
1.0.579-alpha

Platform
Affects all platforms

Symptom & Reproduction
The following succeeds:

(p/parse-string-all "#:abc {:d 1}")
;; => <forms: #:abc {:d 1}>

But when we try the following, it throws

(p/parse-string-all "#:abc \n {:d 1}")
; Execution error (ExceptionInfo) at rewrite-clj.reader/throw-reader (reader.cljc:24).
; namespaced map expects a map [at line 2, column 1

Expected behavior
Rewrite-clj should recognize that all Clojure whitespace is valid between the prefix and map in a namespaced map.

Diagnosis
I discovered this issue while adding cljstyle to out lib tests.
Running its tests against rewrite-clj v1 uncovered the oversight.

Action
This is an easy fix, will address shortly.

@lread lread added the bug label Mar 16, 2021
@lread lread added this to In Progress in rewrite-clj Mar 16, 2021
@lread lread closed this as completed in 61253ea Mar 16, 2021
rewrite-clj automation moved this from In Progress to Done Mar 16, 2021
@sogaiu
Copy link

sogaiu commented Mar 16, 2021

For reference, this is what tree-sitter-clojure does too: https://github.com/sogaiu/tree-sitter-clojure/blob/master/grammar.js#L379-L382

Here _gap means whitespace, a comment (including a terminating newline), or discard / ignore.

Possibly of interest...I had thought that most places one might be able to put whitespace, the other two constructs (comment + newline and discard) would work, but I found a couple of cases where that didn't seem to be so.

For reader conditionals (and the splicing one too), it appears one can put whitespace between #? (or #?@) and what follows but I did not find comments or newlines to work in that spot: https://github.com/sogaiu/tree-sitter-clojure/blob/master/grammar.js#L368-L371

@lread
Copy link
Collaborator Author

lread commented Mar 16, 2021

Thanks @sogaiu! I'll make a TODO to verify rewrite-clj handling in the areas you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants