Fork me on GitHub
#clojure-dev
<
2015-08-06
>
ghadi16:08:53

@bronsa: Tail clearing is broken in t.a.j. due to incorrect code analysis. Proper fix and explanation is in the commit message to http://dev.clojure.org/jira/browse/CLJ-1793

ghadi16:08:31

Turns out all loop bodies are analyzed in RETURN context even if the loop isn't RETURN context

bronsa16:08:58

@ghadi thanks I'll look into that

ghadi16:08:42

Minimal repro:

ghadi16:08:50

(let [x (atom 5)
      bad (fn []
            (loop [] (System/getProperties))
            (swap! x dec)
            (if (pos? @x)
              (recur)
              (count [])))]
 (bad))

ghadi16:08:46

That will NPE on 1.8.0-alpha4. (System/getProperties) is a tail call because loop bodies are always RETURN context

bronsa17:08:05

@ghadi seems to work fine in t.a.j, it's possible I already fixed that

ghadi17:08:47

cool. Wasn't certain you had taken the same (incorrect) approach that I did where C.RETURN == tail call

bronsa17:08:10

@ghadi yeah, I need to take a better look. I just tried your testcase & the one on CLJ-1793 and they don't NPE in t.e.j but I don't recall how the clearing analysis work right now to confirm it's not affected

bronsa17:08:57

@ghadi does this bug manifests itself only with direct linking?

ghadi17:08:20

no, there was a separate bad interaction with direct linking

ghadi17:08:34

i think the analysis pass is probably better than Compiler.java