Way to store what is normally printed in the REPL to a string or file?

code_warntype lets you pass an IO object as the first argument so you can do something like this:

julia> f(x, y) = x * y;

julia> open("file.txt", "w") do io
           code_warntype(io, f, Tuple{Int, Int})
       end
$ cat file.txt
Variables
  #self#::Core.Compiler.Const(f, false)
  x::Int64
  y::Int64

Body::Int64
1 ─ %1 = (x * y)::Int64
└──      return %1
4 Likes