tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

Quote *ns* var in defstate macro to avoid aot compilation issues. #74

Closed mgrbyte closed 7 years ago

mgrbyte commented 7 years ago

Fixes #73

tolitius commented 7 years ago

A couple things:

  1. I just want to confirm that this problem only happens when using lein, since it resuses compiled sources between runs unless it is "clean"ed. If that's the case, boot for example, would not have this problem, because it uses different immutable filesets. But again, I'd like to confirm: is that the case?

  2. I have not checked (I am on vacation at the moment :)), but I don't think this fix works, since boot test would fail.

You mentioned that:

Switching between the two branches and issuing any lein repl/run/ring command will cause re-compilation to be attempted.

what if it is lein do clean, repl/run/ring vs. just lein repl/run/ring?

mgrbyte commented 7 years ago

It's definitely not the lein do clean, repl/run/ring vs not doing a clean first, as this we've tested extensively.

  1. We don't use boot for our project. I'd need to make an equivalent example boot project in order to confirm the issue.
  2. You're correct this patch is not correct. boot test fails.

What the patch aimed to do was to ensure the *ns* dynamic var was quoted within the defstate macro, since, as linked to in #73, it seemed to be a likely cause:

set-logger! is a macro that makes use of the ns var. ns contains the current namespace and, due to what I’m assuming to be special semantics regarding this particular var, it shouldn’t be unquoted within a macro - which is why it was failing in AOT mode

This is the exact behaviour we have experienced - skipping AOT in our lein configuration avoids the issue. Closing as the solution here is invalid, and we can work around the issue. Thanks for looking at it!