weasel icon indicating copy to clipboard operation
weasel copied to clipboard

Referred vars in a namespace are only available after a (load-file)

Open tomjakubowski opened this issue 10 years ago • 3 comments

To reproduce:

  • Run lein cljsbuild once in the example project.
  • Open a REPL in the example project.
  • Open index.html in a browser.
  • Switch to the weasel-example.example NS, and evaluate baz.

The referred var will not be available.

Then, run (load-file "weasel_example/example.cljs"), and try to evaluate baz again. The referred var will be available, and its value will be printed.

tomjakubowski avatar Feb 16 '15 22:02 tomjakubowski

Technically I would not consider this a bug, but you may wish to preserve pre-existing behavior. You will need to analyze a source directory for these things to be available, :cache-analysis will definitely help here if you want to incur small overheads.

swannodette avatar Feb 17 '15 00:02 swannodette

@tomjakubowski FWIW, Ambly exhibits what appears to be similar behavior. You can see this in the README.md instructions for Shrimp (where a require is used in lieu of a load-file to the same effect).

I actually get a WARNING: Use of undeclared Var but with things actually working, unless a require or load-file is first issued. (That's why I said similar behavior. If this is also what you are seeing then it is identical behavior.)

I found that issuing a repl/analyze-source call fixes this, but introduces the challenges I mentioned in #28 where there doesn't appear to be a way to programatically enumerate the source directories that need to be analyzed, and even if it were possible (say by introducing yet another :source-paths), they would need to be in a topological sort reflecting the dependency relation between the source directories.

mfikes avatar Mar 03 '15 04:03 mfikes

autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it

MalloZup avatar Aug 05 '19 21:08 MalloZup