<< Back to previous view

[CTYP-263] Unnecessary type hint required in catch expression Created: 27/Jul/15  Updated: 01/Aug/15

Status: Open
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: 0.3.9
Fix Version/s: 0.3.10, 0.3.x

Type: Defect Priority: Major
Reporter: Mark Feeney Assignee: Ambrose Bonnaire-Sergeant
Resolution: Unresolved Votes: 0
Labels: regression


 Description   

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






Generated at Sat Aug 01 11:13:57 CDT 2015 using JIRA 4.4#649-r158309.