Skip to content

Debugger breaks when applied to vector with a closed-over name #2601

Open
@lvh

Description

@lvh

Expected behavior

This code adds breakpoints wherever possible:

(defn repro
  [x]
  #dbg
  [x])

Actual behavior

When evaling above fn in a way that triggers the debugger machinery, the following exception is raised: "java.lang.RuntimeException Unable to resolve symbol: STATE__ in this context".

Workaround

Adding a do prevents the exception:

(defn repro
  [x]
  #dbg
  (do [x]))

Other details

The bug only occurs in this specific case where you have a vector literal with a closed-over local. Some examples of things that don't break:

  • The local itself: (defn works [x] #dbg x)
  • An empty vector: (defn works [x] #dbg [])
  • A vector with a clojure.core name: (defn works [x] #dbg [next])
  • A set works: (defn works [x] #dbg #{x})
  • A map works, with the var as a key: (defn works [x] #dbg {x :a}) (breaks if it's in a value, though)

However, the bug also occurs when you close over e.g. a required name:

;; io is clojure.java.io
(defn breaks [x] #dbg [io/as-file])

Steps to reproduce the problem

  1. Paste above code in a buffer
  2. C-M-x or C-x e it

Environment & Version information

~ ➤ uname -a                                                                   
Linux cannon 4.20.0-trunk-amd64 #1 SMP Debian 4.20-1~exp1 (2018-12-24) x86_64 GNU/Linux

CIDER version information

;; Connected to nREPL server - nrepl://localhost:42045
;; CIDER 0.22.0-snapshot, nREPL 0.6.0
;; Clojure 1.10.0, Java 10.0.2

Lein/Boot version

Started using cider-jack-in.

~ ➤ lein version                                                               
Leiningen 2.8.3 on Java 10.0.2 OpenJDK 64-Bit Server VM

Emacs version

GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.4) of 2019-02-03, modified by Debian

Operating system

Debian testing

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions