tools.analyzer

Analyzing a function call with type-hinted ret value, where ret type is a class not imported in calling namespace, throws exception

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Shortest example I can find requires a Leiningen project with 2 namespaces.

File project.clj:

(defproject temp "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.5.1"]])

File src/temp/util.clj:

(ns temp.util
  (:import [java.awt Cursor]))

(defn foo ^Cursor []
  (Cursor. Cursor/HAND_CURSOR))

File src/temp/core.clj:

(ns temp.core
  (:require [temp.util :as u]))

(defn foo [x]
  [x (u/foo)])

Eastwood throws exception when analyzing namespace temp.core because of the call to (u/foo). I haven't tried to reproduce it with only calls to tools.analyzer functions.

This is with the latest versions of all code checked in as of the time this ticket was created.

Activity

Hide
Nicola Mometto added a comment - - edited

This is strongly related to #TANAL-24 in that it works in clojure simply because Clojure discards the tag.
It actually doesn't really work in clojure when the :tag info is required, try:

(defn foo [] (.hashCode (u/foo)))

It'll throw the ClassNotFoundException too.

I'll let this ticket open until we close #TANAL-24, and will open a Clojure ticket fixing this behaviour since this is clearly a Clojure bug.

Thanks

Show
Nicola Mometto added a comment - - edited This is strongly related to #TANAL-24 in that it works in clojure simply because Clojure discards the tag. It actually doesn't really work in clojure when the :tag info is required, try:
(defn foo [] (.hashCode (u/foo)))
It'll throw the ClassNotFoundException too. I'll let this ticket open until we close #TANAL-24, and will open a Clojure ticket fixing this behaviour since this is clearly a Clojure bug. Thanks
Hide
Andy Fingerhut added a comment -

Understood. For future reference, below is a list of namespaces where tools.analyzer throws an exception of this kind, with a very similar stack trace going through the following function call:

clojure.tools.analyzer.passes.jvm.emit-form/emit-form

I have not verified if the root cause in the source code is the same for all of them. The short example in the description was cut down from a case in the Seesaw library.

seesaw.widgets.log-window
seesaw.test.core
seesaw.test.examples.hotpotatoes
clojurewerkz.titanium.query
clojurewerkz.titanium.edges-test
clojurewerkz.titanium.element-test
clojurewerkz.titanium.graph-test
clojurewerkz.titanium.integration-test
clojurewerkz.titanium.types-test
clojurewerkz.titanium.vertices-test
flatland.useful.datatypes-test
flatland.useful.experimental-test
cljs.core.async.impl.ioc-macros
cljs.core.async.macros
clojure.core.async-test
clojure.core.match.test.core
clojure.core.match.test.date
clojure.core.match.test.java
clojure.data.codec.test-base64
clojure.data.fressian-test
clojure.java.test-jdbc
clojure.test.array-test
clojure.test.core-test
clojure.test.math-test
clojure.tools.namespace.dependency

Show
Andy Fingerhut added a comment - Understood. For future reference, below is a list of namespaces where tools.analyzer throws an exception of this kind, with a very similar stack trace going through the following function call: clojure.tools.analyzer.passes.jvm.emit-form/emit-form I have not verified if the root cause in the source code is the same for all of them. The short example in the description was cut down from a case in the Seesaw library. seesaw.widgets.log-window seesaw.test.core seesaw.test.examples.hotpotatoes clojurewerkz.titanium.query clojurewerkz.titanium.edges-test clojurewerkz.titanium.element-test clojurewerkz.titanium.graph-test clojurewerkz.titanium.integration-test clojurewerkz.titanium.types-test clojurewerkz.titanium.vertices-test flatland.useful.datatypes-test flatland.useful.experimental-test cljs.core.async.impl.ioc-macros cljs.core.async.macros clojure.core.async-test clojure.core.match.test.core clojure.core.match.test.date clojure.core.match.test.java clojure.data.codec.test-base64 clojure.data.fressian-test clojure.java.test-jdbc clojure.test.array-test clojure.test.core-test clojure.test.math-test clojure.tools.namespace.dependency
Hide
Nicola Mometto added a comment -
Show
Nicola Mometto added a comment - clojure issue: http://dev.clojure.org/jira/browse/CLJ-1307
Hide
Nicola Mometto added a comment -

I'm closing this since it's caused by a Clojure bug and on the tools.analyzer side it's related to #TANAL-24

Show
Nicola Mometto added a comment - I'm closing this since it's caused by a Clojure bug and on the tools.analyzer side it's related to #TANAL-24

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: