<< Back to previous view

[CTYP-259] Rewrite function bodies if they are only checked once Created: 23/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Duplicate Votes: 0
Labels: None


 Description   

Problem

We want to rewrite code in the body of functions if they are
only checked once (ie., the functions are not of an intersection
type that overloads the same arities). Currently, function bodies
are not rewritten directly to the respective AST node they originated
from, in case they are checked more than once.

Solution

If an arity is checked only once, then associate the result of type
checking over the old body. Otherwise, keep the current behaviour.

Pull request:
Patch:
Commit:
Release:



 Comments   
Comment by Ambrose Bonnaire-Sergeant [ 02/Aug/15 1:41 AM ]

Duplicate of CTYP-247.





[CTYP-247] Function bodies should rewrite themselves if possible Created: 19/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

Type: Defect Priority: Major
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Problem

core.typed resolves some reflective Java interop manually if the
Clojure compiler cannot.

(fn [a :- java.io.File] (.getParent a))

However, in some cases, *warn-on-reflection* still says reflection exists.

This especially happens inside function bodies.

The cause is probably mishandled rewriting of composite AST nodes like :fn
or :do which then drops the rewriting on the floor.

Next steps

Minimal failing case.

Pull request: 49
Commits: Fix+test 488c927






[CTYP-265] Anonymous functions should rewrite body Created: 01/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

Status: Resolved
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: 0.3.10

Type: Defect Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Commits:






[CTYP-264] deftype should rewrite method bodies Created: 01/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

Status: Resolved
Project: core.typed
Component/s: Clojure Checker
Affects Version/s: None
Fix Version/s: 0.3.10

Type: Defect Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Commits:






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

Status: Resolved
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: Completed 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
Commits:






[CTYP-250] Resolve Java interoperability based on static type information Created: 21/Jul/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

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

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Problem

Static type information can inform the Clojure compiler of non-reflective
Java interop. With the typed REPL, we now have a means to communicate this
information.

Approach

tools.analyzer.jvm returns :host-interop nodes for unresolved interop.
We first generate type hints based on the static types of the target/argument/
expected type, then passed the type-hinted AST back into the analyzer.

If this doesn't resolve the interop, we throw a type error a usual. If it does,
we type check as usual.

Pull request:

Commit: db3a3






[CTYP-266] Elide checking of ns macro output for performance Created: 02/Aug/15  Updated: 02/Aug/15  Resolved: 02/Aug/15

Status: Resolved
Project: core.typed
Component/s: None
Affects Version/s: None
Fix Version/s: 0.3.10

Type: Enhancement Priority: Minor
Reporter: Ambrose Bonnaire-Sergeant Assignee: Ambrose Bonnaire-Sergeant
Resolution: Completed Votes: 0
Labels: None


 Description   

Problem

Checking the output of the ns macro is very slow.

=> (dotimes [i 3]
     (binding [*ns* *ns*]
       (time (cf (ns foo)))))
"Elapsed time: 527.803116 msecs"
"Elapsed time: 415.179303 msecs"
"Elapsed time: 497.35092 msecs"
nil

tc-ignore'ing the body delivers significant performance enhancements.

;; after patch
=> (dotimes [i 3]
     (binding [*ns* *ns*]
       (time (cf (ns foo)))))
"Elapsed time: 75.241128 msecs"
"Elapsed time: 60.542611 msecs"
"Elapsed time: 57.938648 msecs"
nil

Solution

tc-ignore body of ns macro, with an explicit nil return.

Pull request: 57
Commits: 8ce019d






Generated at Mon Aug 03 16:29:04 CDT 2015 using JIRA 4.4#649-r158309.