[go: nahoru, domu]

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

Fix npe when chaining assoc #11

Merged
merged 1 commit into from
Apr 14, 2022
Merged

Conversation

rfhayashi
Copy link
Contributor

When chaining assocs calls a NullPointerException is thrown. This happens because rewrite-clj only adds the position metadata when parsing the initial string. Using :track-position? (https://cljdoc.org/d/rewrite-clj/rewrite-clj/1.0.767-alpha/doc/user-guide#position-tracking) fixes the issue.

@borkdude borkdude merged commit d3bbafb into borkdude:master Apr 14, 2022
@borkdude
Copy link
Owner

Thanks!

@rfhayashi rfhayashi deleted the chained-assoc branch April 14, 2022 18:54
@rfhayashi
Copy link
Contributor Author
rfhayashi commented Apr 20, 2022

@borkdude I found that this change breaks formatting for nested maps. For example, if you have a map:

{:a {:b 1}}

and do:

(r/assoc-in m [:a :c] 2)

Previously, the resulting map would be:

{:a {:b 1
     :c 2}}

And now:

{:a {:b 1
 :c 2}}

The problem is that z/position returns the position relative to the inner map instead of the outer map. Do you know whether this is expected or it is a bug in rewrite-clj? If you see fit, feel free to revert the PR while we figure this out.

borkdude added a commit that referenced this pull request Apr 20, 2022
@borkdude
Copy link
Owner

I reverted for now. We can revisit another time.

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

Successfully merging this pull request may close these issues.

2 participants