Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging deftype Methods #2453

Closed
cartesian-theatrics opened this issue Sep 16, 2018 · 0 comments
Closed

Debugging deftype Methods #2453

cartesian-theatrics opened this issue Sep 16, 2018 · 0 comments
Assignees

Comments

@cartesian-theatrics
Copy link

cartesian-theatrics commented Sep 16, 2018

The debugger fails when attempting instrument a deftype form. The cause is that the debugger inserts references to to a local variable (cider.nrepl.middleware.debug/STATE__) - binded outside the deftype form - inside the method body. But as stated in the deftype doc, "method bodies are not closures, the local environment includes only the named fields, and those fields can be accessed directly", so not surprisingly it throws with:

Unable to resolve symbol: STATE__ in this context.

There's clearly logic for handling deftype forms in the instrumentation code, but looking at it I'm not sure how it could have ever worked.

In attempting to hack a dirty solution by altering a root var instead of binding a local variable, I was able to instrument the form successfully and begin stepping through the method body, but unfortunately for some reason the :quit command then doesn't work. The eval thread seems to hang.

Steps to reproduce the problem

You can demonstrate by attempting to instrument a deftype form either via. the emacs command or by inserting #debug #dbg in the method body. Also, the cause can be demonstrated easily with:

(let [state 42]
  (deftype Temp [] 
    clojure.lang.IDeref
    (deref [this] state))
  (deref (Temp.)))

I'd be happy to try to patch myself, but haven't yet wrapped my head around the nrepl middleware stuff sufficiently to be able to even really understand the control flow.

CIDER version information

Version: 20180915.645
Commit: baa0430

Lein/Boot version

Leiningen 2.8.1 on Java 1.8.0_181 OpenJDK 64-Bit Server VM

Emacs version

GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2018-05-28

Operating system

Ubuntu 16.01, VM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants