Unnecessary type hint required in catch expression
Description
Environment
None
Activity
Completed
Details
Details
Assignee
Ambrose Bonnaire-Sergeant
Ambrose Bonnaire-SergeantReporter
Mark Feeney
Mark FeeneyLabels
Components
Affects versions
Priority

Created July 27, 2015 at 2:11 PM
Updated December 3, 2017 at 11:07 PM
Resolved December 3, 2017 at 11:07 PM
Problem
Below is a case where core.typed requires a type hint that Clojure itself doesn't.
(Clojure 1.7, core.typed 0.3.9)
user=> *warn-on-reflection* true user=> (try :anything (catch Exception e (.getCause e))) :anything user=> (t/cf (try :anything (catch Exception e (.getCause e)))) Type Error (/tmp/form-init1733185424844917450.clj:1:41) Unresolved host interop: getCause Target java.lang.Exception has no member getCause Hint: use *warn-on-reflection* to identify reflective calls in: (. e getCause) ExceptionInfo Type Checker: Found 1 error clojure.core/ex-info (core.clj:4593)
Adding a hint satisfies core.typed, but is unnecessary for plain Clojure.
user=> (t/cf (try :anything (catch Exception e (.getCause ^Exception e)))) (t/U (t/Val :anything) nil Throwable)
This used to work without the hint. It first started failing here: (git bisect)
be52bc50cb9f5fd7947d744c5045315ecb0561f1 is the first bad commit commit be52bc50cb9f5fd7947d744c5045315ecb0561f1 Author: Ambrose Bonnaire-Sergeant <...@gmail.com> Date: Wed Jul 1 14:14:13 2015 +0800 Upgrade tools.analyzer.jvm from 0.4.0 to 0.6.7.
Notes
Discussion: https://groups.google.com/forum/#!topic/clojure-core-typed/EJIl01yQhPk
tools.analyzer issue: http://dev.clojure.org/jira/browse/TANAL-112
(already fixed in 0.6.8-SNAPSHOT, see thread)
Solution
Bump t.a.j dep to include 966fe1f and add test.
Pull request: 50
Commits:
Fix 7ed102
Test af991f