2

There may be something I really don't understand about core.typed and the way you need to call check-ns.

Here's what's working and then what's not working:

  • lein new default showso
  • Lauching Emacs
  • add the [org.clojure/core.typed "0.2.34"] dependency to project.clj
  • modify core.clj so that it contains:

    (ns showso.core
      :require [clojure.core.typed :refer [ann check-ns AnyInteger]]))
    
    (ann somevar Number)
    (def somevar 42)
    
  • cider-jack-in

  • REPL> (ns showso.core)
  • cider-eval-buffer
  • showsho.core> (check-ns)

    Initializing core.typed ...
    "Elapsed time: 2537.589357 msecs"
    core.typed initialized.
    Start collecting showso.core
    Finished collecting showso.core
    Collected 1 namespaces in 2595.464317 msecs
    Start checking showso.core
    Checked showso.core in 20.24605 msecs
    Checked 1 namespaces (approx. 5 lines) in 2619.38047 msecs
    :ok
    

So so far so good, everything is working fine.

Now what I really don't get at all is that if a modify the (def somevar 42), which must be a Number, to, say, a String, then I simply cannot find a way to have the check-ns function take that change into account:

(def somevar "bugsme")

Now, no matter what I try: cider-eval-buffer, cider-eval-last-expression, redefining somevar directly from the repl, etc. apparently nothing I do makes check-ns take the changes into account.

It's as if the results from the last check-ns was cached somewhere and never re-running.

Even if I kill all the cider Emacs buffers and relaunch cider-jack-in, the changes are still not taking into account. check-ns keeps telling me everything is ok.

The only way I can have check-ns take the change into account is to entirely close Emacs and relaunch it.

Note that it's exactly the same if I first test with a bogus value: then check-ns correctly finds the type mismatch ("Expected: java.lang.Number"...) but then if I fix it there's no way besides relaunching Emacs to have check-ns report no error.

What am I doing wrong? Is there some caching of previous values going on?

Is there an easy way to "force" check-ns to take the changes into account, directly from Emacs, without having to launch a new REPL (not even sufficient in my case) / relaunching Emacs?

1 Answer 1

4

You should save the file before each call to check-ns.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.