bhauman / lein-figwheel

Figwheel builds your ClojureScript code and hot loads it into the browser as you are coding!
Eclipse Public License 1.0
2.88k stars 209 forks source link

Quoted symbols in config result in confusing error message #562

Open bhb opened 7 years ago

bhb commented 7 years ago

I'm using lein-figwheel "0.5.10" and figwheel-sidecar "0.5.10".

Repro:

  1. In project.clj, add the following (admittedly nonidiomatic) build config under :cljsbuild
{:id "test"
 :source-paths ["src" "test"]
 :compiler {:output-to "target/test.js"
            :output-dir "target/test-web"
            :main "foobar.test-runner"
            :optimizations :none
            :preloads ['foobar.preload]}}
  1. lein figwheel :check-config

Actual:

------ Figwheel Configuration Error ------

The Vector at (:cljsbuild :builds 3 :compiler :preloads) contains a non-conforming value:
  'foobar.preload
It should be a Symbol

But if I check this at the REPL, the issue isn't apparent

user=> (type 'foobar.preload)
clojure.lang.Symbol

Expected: Could the error message explain more clearly what is wrong? AIUI, the value is a symbol, although it is a symbol with the name 'foobar.preload (with a leading quote).

Perhaps the issue is that a symbol should not have a name that begins with ', since that indicates over-quoting.

This could potentially be an issue with strictly-specking, and if so, I'm happy to come up with a more narrow example and post the issue there. However, when I pulled master from strictly-specking, I couldn't seem to reproduce (I may be using the library incorrectly though!)

  (require '[clojure.edn :as edn])
  (require '[clojure.spec :as s])
  (require '[strictly-specking.core :as ss])
  (ss/def-key ::preloads1 (s/every symbol? :min-count 1 :into [] :kind sequential?))
  (s/def ::opts (ss/strict-keys :opt-un [::preloads1]))
  ;; Note that `foo` is over-quoted, but `bar` is not.
  (s/explain-str ::opts (edn/read-string "{:preloads1 ['foo bar]}")) ; => "Success!\n"

The solution, of course, is to not quote the symbol (as instructed here) but I suspect this is a common mistake, so a more precise error message would be quite useful.

pkpkpk commented 7 years ago

Leiningen implicitly quotes symbols, this should be taken up there (too)

On Wed, Jun 21, 2017 at 11:05 AM, Ben Brinckerhoff <notifications@github.com

wrote:

I'm using lein-figwheel "0.5.10" and figwheel-sidecar "0.5.10".

Repro:

  1. In project.clj, add the following (admittedly nonidiomatic) build config under :cljsbuild

{:id "test" :source-paths ["src" "test"] :compiler {:output-to "target/test.js" :output-dir "target/test-web" :main "foobar.test-runner" :optimizations :none :preloads ['foobar.preload]}}

  1. lein figwheel :check-config

Actual:

------ Figwheel Configuration Error ------

The Vector at (:cljsbuild :builds 3 :compiler :preloads) contains a non-conforming value: 'foobar.preload It should be a Symbol

But if I check this at the REPL, the issue isn't apparent

user=> (type 'foobar.preload) clojure.lang.Symbol

Expected: Could the error message explain more clearly what is wrong? AIUI, the value is a symbol, although it is a symbol with the name 'foobar.preload (with a leading quote).

Perhaps the issue is that a symbol should not have a name that begins with ', since that indicates over-quoting.

This could potentially be an issue with strictly-specking, and if so, I'm happy to come up with a more narrow example and post the issue there. However, when I pulled master from strictly-specking, I couldn't seem to reproduce (I may be using the library incorrectly though!)

(require '[clojure.edn :as edn]) (require '[clojure.spec :as s]) (require '[strictly-specking.core :as ss]) (ss/def-key ::preloads1 (s/every symbol? :min-count 1 :into [] :kind sequential?)) (s/def ::opts (ss/strict-keys :opt-un [::preloads1])) ;; Note that foo is over-quoted, but bar is not. (s/explain-str ::opts (edn/read-string "{:preloads1 ['foo bar]}")) ; => "Success!\n"

The solution, of course, is to not quote the symbol (as instructed here https://github.com/clojure/clojurescript/wiki/Compiler-Options#preloads) but I suspect this is a common mistake, so a more precise error message would be quite useful.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bhauman/lein-figwheel/issues/562, or mute the thread https://github.com/notifications/unsubscribe-auth/ADrVA-4laWQFkaTUjKDBEYbx_RpQL2xhks5sGTEmgaJpZM4OBGan .