tools.analyzer

Should type-hint exceptions inside catch expressions?

Details

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

Description

Clojure 1.5.1 gives no reflection warning at all for the following source file, but eval'ing the result of emit-form gives this warning:

Reflection warning, reflection/core4.clj:11:16 - reference to field getMessage can't be resolved.

Here is the code:

(ns reflection.core4)

(set! *warn-on-reflection* true)

;; copied & trimmed down from namespace reply.main

(defn foo [arg]
  (try
    (read-string arg)
    (catch Exception e
      (println (.getMessage e)))))

Activity

Hide
Nicola Mometto added a comment -

Well this one is weird.
Looks like if the classname to a catch is a Class, the local will not get type hinted but the catch will work fine anyway.

Fixed: https://github.com/clojure/tools.analyzer.jvm/commit/c79c5f8e8cb96a323360fb75c86bf10c41b83082

Show
Nicola Mometto added a comment - Well this one is weird. Looks like if the classname to a catch is a Class, the local will not get type hinted but the catch will work fine anyway. Fixed: https://github.com/clojure/tools.analyzer.jvm/commit/c79c5f8e8cb96a323360fb75c86bf10c41b83082

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: