Fork me on GitHub
#cljs-dev
<
2016-11-03
>
Roman Liutikov14:11:22

@dnolen I just got invalid local name error when compiling a macro in ClojureScript, it turned out that I need to use gensym form. This was very confusing and didn’t really help, could we improve this error message to refer directly to what should be done to solve it?

dnolen14:11:34

@roman01la but what is there to detect?

dnolen14:11:54

@roman01la which is to say- a) determine what is the typical mistake (is even typical?), b) how can we detect it, and then c) assess whether it’s worth the trouble

dnolen14:11:16

if you can reasonably answer all these then open a ticket & submit a patch

Roman Liutikov14:11:57

@dnolen I assume this error popups when there's possible naming collision? (At least that what I can tell from looking at analyze-let-bindings* fn) If so, this could be changed to something like Naming collision. Invalid local name...

dnolen14:11:47

@roman01la don’t assume anything 🙂

dnolen14:11:57

figure out what the problem is then come up with a solution

dnolen14:11:20

you haven’t even shown a example of the mistake yet

dnolen14:11:46

if you don’t understand the problem - no screenshots do not help 🙂

dnolen14:11:51

that doesn’t mean anything to me

dnolen15:11:00

anyways - the first thing you need to do is create something minimal

dnolen15:11:09

there’s nothing to talk about until we can both see that

Roman Liutikov15:11:00

@dnolen do you want a minimal project or a gist would be enough?

dnolen15:11:03

no project

dnolen15:11:12

come up with a minimal code snippet

Roman Liutikov15:11:41

sure Here I need to gensym every var within loop to compile the macro. I guess it’s because loop is being compiled to JS while loop which doesn’t have a scope.

(defmacro fast-mapv [f data]
  `(loop [[x & xs] ~data
          result []]
     (let [nresult (conj result (~f x))]
       (if (seq xs)
         (recur xs nresult)
         nresult))))

(fast-mapv inc [1 2 3])

dnolen15:11:08

@roman01la doesn’t the compiler emit a bunch of warnings?

Roman Liutikov15:11:40

@dnolen nope, that’s the only error reported by figwheel. the same goes to REPL

dnolen15:11:09

@roman01la figwheel doesn’t have anything do with this

dnolen15:11:24

reporting problems via Figwheel is a huge waste of time

dnolen15:11:30

try this without Figwheel please

Roman Liutikov15:11:02

@dnolen I’m not sure how this can help, could you please explain? Figwheel is the tool which I’m using daily, so I rely on it.

dnolen15:11:01

@roman01la reporting issues via other tooling is a huge waste of time

dnolen15:11:09

it introduces variables to the problem

dnolen15:11:24

if you’re going to try to understand some compiler issue, report only by using the compiler

dnolen15:11:41

I’ve lost hours chasing down bugs that aren’t bugs but tooling stuff

dnolen15:11:44

I’m not doing that anymore

Roman Liutikov15:11:08

@dnolen ok, I understand. Thank you. I'll get back when I'll try compiler directly.

dnolen15:11:02

much appreciated