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

warning-handlers: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn #494

Open
pesterhazy opened this issue Aug 22, 2018 · 2 comments

Comments

@pesterhazy
Copy link

The warning-handlers key doesn't seem to work as explained in the docs.

Check this demo repo, the simple result of doing lein new figwheel asdf and adding the warning-handlers key.

When you run

lein cljsbuild once

in the repo you get the following exception

clojure.lang.ExceptionInfo: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn at line 3 src/asdf/core.cljs {:file "src/asdf/core.cljs", :line 3, :column 1, :tag :cljs/analysis-error}

It looks as though the (fn ...) form is interpreted literally, as a list, rather than evaluated to a fn. But as I understand the docs this is how to use the feature.

A similar exception is caused when using a symbol:

Wrong number of args (3) passed to: Symbol

Not sure if this is cljsbuild issue or a clojurescript compiler issue.

@lread
Copy link

lread commented Apr 14, 2019

@pesterhazy, I made the very same mistake you did.
The :warning-handlers does not go under :compiler, it is specified at the same level as :compiler.
The README clearly shows this, but somehow I messed it up too.

(defproject lein-cljsbuild-example "1.2.3"
  :plugins [[lein-cljsbuild "1.0.4"]]
  :cljsbuild {
    :builds {:id           "example"
             :compiler     {}
             :warning-handlers [my.ns/custom-warning-handler ;; Fully-qualified symbol
                                ;; Custom function (to be evaluated at project build-time)
                                (fn [warning-type env extra]
                                  (when-let [s (cljs.analyzer/error-message warning-type extra)]
                                    (binding [*out* *err*]
                                      (cljs.analyzer/message env s))))]}})

@danielcompton
Copy link
Contributor

I have also made this class of mistake before at #437 😄.

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

No branches or pull requests

3 participants