JuliaLang/julia — pull request #9349 by timholy (2014-12-14 00:20:02+00:00)
Title: RFC: highlighting type problems

One of the major "services" that julia developers provide on the mailing lists is helping people solve performance problems due to type instability. It's pretty easy to make such errors (I've made more than a few in my own time), but personally, I'd like to spend less time on such support issues. As usual, my response is to say "we need easier/more powerful analysis tools." So, here's proposing a new macro,

```julia
@code_typewarn myfunction(args...)
```
which produces output like this:

![typewarn](https://cloud.githubusercontent.com/assets/1525481/5425885/d1a5af56-82f1-11e4-88a6-9df51d5cd26c.png)

In the course of testing this I discovered #9345, and might not have noticed it without the red highlighting.

I see two main paths for this facility: it goes in base (aka, this PR; note it's not a lot of code), or it goes in a package like TypeCheck.jl or Lint.jl. I was originally planning on submitting it to TypeCheck, but it occurred to me that if folks think this should belong in base, then I'd just be giving @astrieanna a support headache by putting it in the package and then migrating it out again. So I thought I'd start here and see what people say.

Warnings: this does nassty, wicked things to our hobbitses, erm, the printing of types. It's quite possible that using this will bork your julia session in much the same way as "convertalypse" or #9315. (It did once for me during testing, albeit before it was fully working.) I would also characterize the testing of this as "minimal," on perhaps 20 functions. Hence the RFC.