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

Custom auto-resolve is not applied for :track-position? zippers #159

Closed
lread opened this issue Jul 1, 2021 · 0 comments
Closed

Custom auto-resolve is not applied for :track-position? zippers #159

lread opened this issue Jul 1, 2021 · 0 comments
Labels
Projects

Comments

@lread
Copy link
Collaborator

lread commented Jul 1, 2021

Version
1.0.644-alpha

Platform
all

Symptom
When specifying a custom :auto-resolve fn on a zipper that also specifies :track-position? true, the custom auto-resolve function is not applied.

Reproduction

(require '[rewrite-clj.zip :as z])

(-> "::kw"
    (z/of-string {:track-position? true
                  :auto-resolve (constantly 'testing123) })
    z/sexpr)

Actual behavior
The default auto-resolve behaviour is applied.

;; => :?_current-ns_?/kw

Expected behavior
The custom auto-resolve fn should be applied and return:

;; => :testing123/kw

... as it does when :track-position? is not included in zipper options:

(-> "::kw"
    (z/of-string {:auto-resolve (constantly 'testing123) })
    z/sexpr)
;; => :testing123/kw

Diagnosis
The zipper options are intended to be stored as metadata on the zipper.
This is not-working/lost for :track-position? zippers.

Action
I shall dig in and follow up with a fix.

@lread lread changed the title Custom auto-resolve is not applied for :track-position zippers Custom auto-resolve is not applied for :track-position? zippers Jul 1, 2021
@lread lread added this to In Progress in rewrite-clj Jul 1, 2021
@lread lread added the bug label Jul 1, 2021
@lread lread closed this as completed in 1e1d1df Jul 3, 2021
rewrite-clj automation moved this from In Progress to Done Jul 3, 2021
yannvanhalewyn added a commit to yannvanhalewyn/babashka that referenced this issue Oct 25, 2021
There is a bug in rewrite-clj v644 causing users to be unable to use
`:track-position` and `:auto-resolve` options at the same time in
rewrite zippers. See:

clj-commons/rewrite-clj#159

This makes, for example, building static code analysis tools with
babashka much harder. In fact when analysing code, the position is
relevant for the script output and resolving keywords and symbols might
be required for the analysis.
borkdude pushed a commit to babashka/babashka that referenced this issue Oct 25, 2021
There is a bug in rewrite-clj v644 causing users to be unable to use
`:track-position` and `:auto-resolve` options at the same time in
rewrite zippers. See:

clj-commons/rewrite-clj#159

This makes, for example, building static code analysis tools with
babashka much harder. In fact when analysing code, the position is
relevant for the script output and resolving keywords and symbols might
be required for the analysis.
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

1 participant