clojure-emacs / clj-refactor.el

A CIDER extension that provides powerful commands for refactoring Clojure code.
GNU General Public License v3.0
771 stars 111 forks source link

cljr-create-fn-from-example breaks if arg calls .. macro #446

Closed barrosfelipe closed 5 years ago

barrosfelipe commented 5 years ago

Expected behavior

Given:

(foo (.. bar)

Inside foo sexp, invoke cljr-create-fn-from-example. Expected:

(defn- foo [arg0]
  )

(foo (.. bar))

Actual behavior

Get error cljr--guess-param-name: Wrong type argument: char-or-string-p, nil.

Steps to reproduce the problem

I have used the figwheel-main template via clj-new.

clj -A:new figwheel-main namespace/project

Enter the ClojureScript file and jack-in passing the -R:fig flag to cider-jack-in-cljs.

Choose figwheel-main and profile dev without colon.

On the ClojureScript file, try the above.

Environment & Version information

clj-refactor.el version information

clj-refactor 2.5.0-SNAPSHOT (package: 20190618.716), refactor-nrepl 2.5.0-SNAPSHOT

CIDER version information

;; CIDER 0.22.0snapshot (package: 20190718.1550), nREPL 0.6.0
;; Clojure 1.9.0, Java 1.8.0_202

Leiningen or Boot version

Emacs version

GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-07-24

Operating system

Ubuntu Linux 18.04

expez commented 5 years ago

This functionality isn't supported in clojurescript. We have to build an AST to find the unbound variables (which will be the parameters of the new function). Since we're unable to build an AST for Clojurescript, and get those variables, we end up pushing nil further down the stack where it eventually blows up.

I'll close this issue here, because it's really the middleware's job to either signal that it can't handle this request or to gain some better cljs support.

Thanks for the report, and sorry about the crappy failure mode!