<p dir="auto">There's a strange bug that is causing segfaults and other behaviour in Julia 0.4 that's being triggered in ApproxFun. Sorry I haven't been able to narrow it down further but I reduced it to the following, where <code class="notranslate">S.op</code> is bizarrely a <code class="notranslate">DataType</code> instead of an instance of the type:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Pkg.checkout(&quot;ApproxFun&quot;,&quot;development&quot;)
using ApproxFun
import ApproxFun: SpaceOperator

m=MappedSpace(Ray(),Ultraspherical{1}())    
sp=MappedSpace(Ray(),JacobiWeight(0.,-1.,Ultraspherical{1}()))
C=Conversion(m.space,sp.space)
S=SpaceOperator(C,m,sp)
S.op|&gt;typeof    # returns DataType instead of typeof(C)"><pre class="notranslate">Pkg<span class="pl-k">.</span><span class="pl-c1">checkout</span>(<span class="pl-s"><span class="pl-pds">"</span>ApproxFun<span class="pl-pds">"</span></span>,<span class="pl-s"><span class="pl-pds">"</span>development<span class="pl-pds">"</span></span>)
<span class="pl-k">using</span> ApproxFun
<span class="pl-k">import</span> ApproxFun<span class="pl-k">:</span> SpaceOperator

m<span class="pl-k">=</span><span class="pl-c1">MappedSpace</span>(<span class="pl-c1">Ray</span>(),<span class="pl-c1">Ultraspherical</span><span class="pl-c1">{1}</span>())    
sp<span class="pl-k">=</span><span class="pl-c1">MappedSpace</span>(<span class="pl-c1">Ray</span>(),<span class="pl-c1">JacobiWeight</span>(<span class="pl-c1">0.</span>,<span class="pl-k">-</span><span class="pl-c1">1.</span>,<span class="pl-c1">Ultraspherical</span><span class="pl-c1">{1}</span>()))
C<span class="pl-k">=</span><span class="pl-c1">Conversion</span>(m<span class="pl-k">.</span>space,sp<span class="pl-k">.</span>space)
S<span class="pl-k">=</span><span class="pl-c1">SpaceOperator</span>(C,m,sp)
S<span class="pl-k">.</span>op<span class="pl-k">|&gt;</span>typeof    <span class="pl-c"><span class="pl-c">#</span> returns DataType instead of typeof(C)</span></pre></div>
<p dir="auto">The definition of <code class="notranslate">SpaceOperator</code> doesn't allow <code class="notranslate">S.op</code> to be a DataType:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="immutable SpaceOperator{T,O&lt;:Operator,S&lt;:FunctionSpace,V&lt;:FunctionSpace} &lt;: BandedOperator{T}
    op::O
    domainspace::S
    rangespace::V
end"><pre class="notranslate">immutable SpaceOperator{T,O<span class="pl-k">&lt;:</span><span class="pl-c1">Operator</span>,S<span class="pl-k">&lt;:</span><span class="pl-c1">FunctionSpace</span>,V<span class="pl-k">&lt;:</span><span class="pl-c1">FunctionSpace</span>} <span class="pl-k">&lt;:</span> <span class="pl-c1">BandedOperator{T}</span>
    op<span class="pl-k">::</span><span class="pl-c1">O</span>
    domainspace<span class="pl-k">::</span><span class="pl-c1">S</span>
    rangespace<span class="pl-k">::</span><span class="pl-c1">V</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">I believe the bug is triggered by an error in a Base.convert overrides, but even so, it shouldn't propagate like this.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; type Foo{N}
         x::Array{Int,N}
       end

julia&gt; Foo() = Foo([1,2,3])
Foo{N}

julia&gt; @which Foo()
call(::Type{Foo{N}}) at none:1

julia&gt; @code_typed Foo()
1-element Array{Any,1}:
 :($(Expr(:lambda, Any[symbol(&quot;#s1&quot;),:(args::Any...)], Any[Any[],Any[Any[symbol(&quot;#s1&quot;),Type{Foo{N}},0],Any[:args,Tuple{},0]],Any[],Any[]], :(begin  # essentials.jl, line 44:
        return (top(typeassert))(convert(T),T)::Foo{N}
    end::Foo{N}))))

julia&gt; code_typed(call, Tuple{Type{Foo}})
1-element Array{Any,1}:
 :($(Expr(:lambda, Any[symbol(&quot;##1936&quot;)], Any[Any[],Any[],Any[],Any[Array{Int64,1}]], :(begin  # none, line 1:
        GenSym(0) = (top(vect))(1,2,3)::Array{Int64,1}
        return $(Expr(:new, Foo{1}, GenSym(0)))
    end::Foo{1}))))"><pre class="notranslate">julia<span class="pl-k">&gt;</span> type Foo{N}
         x<span class="pl-k">::</span><span class="pl-c1">Array{Int,N}</span>
       <span class="pl-k">end</span>

julia<span class="pl-k">&gt;</span> <span class="pl-en">Foo</span>() <span class="pl-k">=</span> <span class="pl-c1">Foo</span>([<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>])
Foo{N}

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@which</span> <span class="pl-c1">Foo</span>()
<span class="pl-c1">call</span>(<span class="pl-k">::</span><span class="pl-c1">Type{Foo{N}}</span>) at none<span class="pl-k">:</span><span class="pl-c1">1</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@code_typed</span> <span class="pl-c1">Foo</span>()
<span class="pl-c1">1</span><span class="pl-k">-</span>element Array{Any,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 :(<span class="pl-k">$</span>(<span class="pl-c1">Expr</span>(<span class="pl-c1">:lambda</span>, Any[<span class="pl-c1">symbol</span>(<span class="pl-s"><span class="pl-pds">"</span>#s1<span class="pl-pds">"</span></span>),:(args<span class="pl-k">::</span><span class="pl-c1">Any...</span>)], Any[Any[],Any[Any[<span class="pl-c1">symbol</span>(<span class="pl-s"><span class="pl-pds">"</span>#s1<span class="pl-pds">"</span></span>),Type{Foo{N}},<span class="pl-c1">0</span>],Any[<span class="pl-c1">:args</span>,Tuple{},<span class="pl-c1">0</span>]],Any[],Any[]], :(<span class="pl-k">begin</span>  <span class="pl-c"><span class="pl-c">#</span> essentials.jl, line 44:</span>
        <span class="pl-k">return</span> (<span class="pl-c1">top</span>(typeassert))(<span class="pl-c1">convert</span>(T),T)<span class="pl-k">::</span><span class="pl-c1">Foo{N}</span>
    <span class="pl-k">end</span><span class="pl-k">::</span><span class="pl-c1">Foo{N}</span>))))

julia<span class="pl-k">&gt;</span> <span class="pl-c1">code_typed</span>(call, Tuple{Type{Foo}})
<span class="pl-c1">1</span><span class="pl-k">-</span>element Array{Any,<span class="pl-c1">1</span>}<span class="pl-k">:</span>
 :(<span class="pl-k">$</span>(<span class="pl-c1">Expr</span>(<span class="pl-c1">:lambda</span>, Any[<span class="pl-c1">symbol</span>(<span class="pl-s"><span class="pl-pds">"</span>##1936<span class="pl-pds">"</span></span>)], Any[Any[],Any[],Any[],Any[Array{Int64,<span class="pl-c1">1</span>}]], :(<span class="pl-k">begin</span>  <span class="pl-c"><span class="pl-c">#</span> none, line 1:</span>
        <span class="pl-en">GenSym</span>(<span class="pl-c1">0</span>) <span class="pl-k">=</span> (<span class="pl-c1">top</span>(vect))(<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>)<span class="pl-k">::</span><span class="pl-c1">Array{Int64,1}</span>
        <span class="pl-k">return</span> <span class="pl-k">$</span>(<span class="pl-c1">Expr</span>(<span class="pl-c1">:new</span>, Foo{<span class="pl-c1">1</span>}, <span class="pl-c1">GenSym</span>(<span class="pl-c1">0</span>)))
    <span class="pl-k">end</span><span class="pl-k">::</span><span class="pl-c1">Foo{1}</span>))))</pre></div>