clj-refactor.el icon indicating copy to clipboard operation
clj-refactor.el copied to clipboard

Inline-symbol fails when core.async rewrites the code

Open magnars opened this issue 9 years ago • 3 comments

I guess the major rewrites of code that core.async does is a major hurdle for clj-refactor, quite possibly insurmountable. Here is an issue either way. Reproduce like this:

(ns example
  (:require [clojure.core.async :refer [timeout go <!]]))

(go
    (loop []
      (<! (timeout 10))
      (let [foos [1 2 3]]
        (doseq [foo foos]
          (prn foo)))))

Try to inline the foos symbol, get let*: Wrong type argument: hash-table-p, nil

magnars avatar Jul 03 '15 15:07 magnars

that may be fixed when find-macros branch get merged into master of refactor-nrepl, not sure tho...

benedekfazekas avatar Jul 03 '15 15:07 benedekfazekas

This is a bug in find-symbol which cljr-inline-symbol relies on. If you run find-usages on the final foos you'll get:

src/refactor_nrepl/test.clj:9: (doseq [foo foos]
src/refactor_nrepl/test.clj:9: (doseq [foo foos]

This bug will not be fixed in the find-macros branch which is only concerned with finding macro definitions and usages and not the occurrences of regular symbols in the bodies of macros.

expez avatar Jul 04 '15 11:07 expez

@benedekfazekas can you take a look at this? I don't understand why it doesn't find foos. go does some pretty nasty re-rewriting, but if you expand that macro there's obviously a let binding matching foos in there and that should be found, right?

expez avatar Oct 12 '15 12:10 expez