Clojure

Locals cleared too aggressively on delay

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.2
  • Component/s: None
  • Labels:
    None

Description

Steve Gilardi and I noticed some strange behaviour with local clearing in conjunction with delay:

(defn do-something [x]
(throw (Exception.)))

(defn clear-locals [x]
(delay (try (do-something x)
(catch Exception e
(println "argument value:" x)))))

(force (clear-locals :argument))
;; => argument value: nil

It seems the locals are getting cleared a little too aggressively here. I did some digging to discover that delay is a thin wrapper around an fn, but using an fn in this context (rather than a delay) does not trigger the problem. Also I found that throwing an exception directly inside the try block (rather than in a function called from the try block) did not trigger it.

I was able to reproduce in the new branch, the master branch, and 1.0.0, so it's not related to the more recent locals-clearing changes.

Activity

No changes have yet been made on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: