plumatic / dommy

A tiny ClojureScript DOM manipulation and event library
758 stars 74 forks source link

Compilation warnings on Clojure 1.7 #83

Closed sritchie closed 9 years ago

sritchie commented 9 years ago

When I try to compile cljs with Clojure 1.7, I see a bunch of warnings like this:

WARNING: Use of undeclared Var dommy.template/->node-like at line 37 file:/Users/sritchie/.m2/repository/prismatic/dommy/0.1.3/dommy-0.1.3.jar!/dommy/attrs.cljs

I'm guessing that requiring dommy.template in that namespace will fix this up.

ccfontes commented 9 years ago

@sritchie I have the same issue. Did you manage to solve it? I opened that jar file and read /dommy/attrs.cljs. It's amazing to find there is no symbol ->node-like anywhere in the file! So the warning message is at the very least fascinating.

ccfontes commented 9 years ago

Downgrading clojurescript to version 0.0-2322 mysteriously solves the issue.

sritchie commented 9 years ago

Well, it's coming in from the macro definition (on my phone now, so can't link). Check the line the error references, then see the definition of that macro.

— Sent from Mailbox

On Sat, Oct 4, 2014 at 4:08 PM, Carlos Cunha notifications@github.com wrote:

Downgrading clojurescript to version 0.0-2322 mysteriously solves the issue.

Reply to this email directly or view it on GitHub: https://github.com/Prismatic/dommy/issues/83#issuecomment-57920031

ccfontes commented 9 years ago

It's amazing to find there is no symbol ->node-like anywhere in the file!

There's nothing in that line as I have mentioned before.

Maybe it's spurious. Not even sure it had any impact in my app.

sritchie commented 9 years ago

Okay, back at my computer.

At line 37, that warning comes in because of the macroexpansion of node here: https://github.com/Prismatic/dommy/blob/master/src/dommy/attrs.cljs#L37

Here's the code for node:

https://github.com/Prismatic/dommy/blob/master/src/dommy/macros.clj#L155

So that line gets expanded to (dommy.template/->node-like ~data) before getting passed into the cljs compiler. That's why it thinks that that symbol exists on that line, because of macro-expansion.

There's no actual error when you run your program if, down the road, some other file requires dommy.template.

The solution would be to require dommy.template in dommy.attrs. This would kill the warnings.

ccfontes commented 9 years ago

Thanks for the in-depth investigation.

The solution would be to require dommy.template in dommy.attrs. This would kill the warnings.

So this is a problem with the compiler. But polluting the codebase with requires for every similar problem doesn't seem correct, imo.

I prefer to not the use that compiler version until the issue is fixed.

sritchie commented 9 years ago

Sure, fine by me. Closing.

jeluard commented 9 years ago

It's not clear to me that this is a compiler bug. The compiler has been recently enhanced to catch more issues so it might be the case here. @ccfontes If you believe that this is a compiler issue maybe it should be tracked in the CLJS JIRA?

jeluard commented 9 years ago

I understand from the response to this question that the node macro could be modified to fix the warning. It would also be safer as current code should not run and might break in the future.

Maybe this issue should be reopened?

swannodette commented 9 years ago

This is not a ClojureScript compiler bug. It should be documented in the library what dependencies are implied by macro usage.