<p dir="auto">This code:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="type A end
Base.convert{F}(::Type{A}, x::F, v::Union{F,Vector{F}} = one(F)) = A()"><pre class="notranslate">type A <span class="pl-k">end</span>
Base<span class="pl-k">.</span><span class="pl-en">convert</span><span class="pl-c1">{F}</span>(<span class="pl-k">::</span><span class="pl-c1">Type{A}</span>, x<span class="pl-k">::</span><span class="pl-c1">F</span>, v<span class="pl-k">::</span><span class="pl-c1">Union{F,Vector{F}}</span> <span class="pl-k">=</span> <span class="pl-en">one</span>(F)) <span class="pl-k">=</span> <span class="pl-c1">A</span>()</pre></div>
<p dir="auto">on Julia v0.4.3 gives</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; convert(A, 0.1)
A()

julia&gt; convert(A, 0.1, 0.2)
A()

julia&gt; convert(A, 0.1, [0.2])
ERROR: MethodError: `convert` has no method matching convert(::Type{A}, ::Float64, ::Array{Float64,1})
This may have arisen from a call to the constructor A(...),
since type constructors fall back to convert methods.
Closest candidates are:
  convert{F}(::Type{A}, ::F)
  convert{F}(::Type{A}, ::F, ::Union{Array{F,1},F})
  call{T}(::Type{T}, ::Any)
  ..."><pre class="notranslate"><code class="notranslate">julia&gt; convert(A, 0.1)
A()

julia&gt; convert(A, 0.1, 0.2)
A()

julia&gt; convert(A, 0.1, [0.2])
ERROR: MethodError: `convert` has no method matching convert(::Type{A}, ::Float64, ::Array{Float64,1})
This may have arisen from a call to the constructor A(...),
since type constructors fall back to convert methods.
Closest candidates are:
  convert{F}(::Type{A}, ::F)
  convert{F}(::Type{A}, ::F, ::Union{Array{F,1},F})
  call{T}(::Type{T}, ::Any)
  ...
</code></pre></div>
<p dir="auto">I would expect that the last call also works. If I define <code class="notranslate">convert()</code>, where <code class="notranslate">F</code> is replaced by <code class="notranslate">Float64</code>, it works.</p>
<p dir="auto">On v0.5 from the juliabox.org</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; convert(A, 0.1)                                                                                                                                                                                                                                                                                                    
A(Error showing value of type A:                                                                                                                                                                                                                                                                                          
ERROR: MethodError: `one` has no method matching one(::Type{A})                                                                                                                                                                                                                                                           
 [inlined code] from ./none:1                                                                                                                                                                                                                                                                                             
 in Type(Type{Pair{A,B}}, Symbol, A) at ./operators.jl:507                                                                                                                                                                                                                                                                
 in show_default(Base.#show_default, IOContext{Base.Terminals.TTYTerminal}, Any) at ./show.jl:80                                                                                                                                                                                                                          
 [inlined code] from ./show.jl:73                                                                                                                                                                                                                                                                                         
 in showcompact(Base.#showcompact, Base.Terminals.TTYTerminal, A) at ./show.jl:1432                                                                                                                                                                                                                                       
 in writemime(Base.Multimedia.#writemime, Base.Terminals.TTYTerminal, MIME{symbol(&quot;text/plain&quot;)}, A) at ./replutil.jl:4                                                                                                                                                                                                   
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, MIME{symbol(&quot;text/plain&quot;)}, Any) at ./REPL.jl:114                                                                                                                                                                                    
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Any) at ./REPL.jl:117                                                                                                                                                                                                                
 [inlined code] from ./multimedia.jl:151                                                                                                                                                                                                                                                                                  
 in display(Base.Multimedia.#display, Any) at ./multimedia.jl:163                                                                                                                                                                                                                                                         
 in print_response(Base.REPL.#print_response, Base.Terminals.TTYTerminal, Any, Void, Bool, Bool, Void) at ./REPL.jl:134                                                                                                                                                                                                   
 in print_response(Base.REPL.#print_response, Base.REPL.LineEditREPL, Any, Void, Bool, Bool) at ./REPL.jl:121                                                                                                                                                                                                             
 in #18(Base.REPL.##18#19{Bool,Base.#parse_input_line,Base.REPL.LineEditREPL,Base.LineEdit.Prompt}, Base.LineEdit.MIState, Base.AbstractIOBuffer{Array{UInt8,1}}, Bool) at ./REPL.jl:626                                                                                                                                  
 in run_interface at ./LineEdit.jl:1611                                                                                                                                                                                                                                                                                   
 in run_frontend at ./REPL.jl:859                                                                                                                                                                                                                                                                                         
 in run_repl(Base.REPL.#run_repl, Base.REPL.LineEditREPL, Base.##479#480) at ./REPL.jl:167                                                                                                                                                                                                                                
 in _start at ./client.jl:342                                                                                                                                                                                                                                                                                             

julia&gt; convert(A, 0.1, 0.1)                                                                                                                                                                                                                                                                                               
A(Error showing value of type A:                                                                                                                                                                                                                                                                                          
ERROR: MethodError: `one` has no method matching one(::Type{A})                                                                                                                                                                                                                                                           
 [inlined code] from ./none:1                                                                                                                                                                                                                                                                                             
 in Type(Type{Pair{A,B}}, Symbol, A) at ./operators.jl:507                                                                                                                                                                                                                                                                
 in show_default(Base.#show_default, IOContext{Base.Terminals.TTYTerminal}, Any) at ./show.jl:80                                                                                                                                                                                                                          
 [inlined code] from ./show.jl:73                                                                                                                                                                                                                                                                                         
 in showcompact(Base.#showcompact, Base.Terminals.TTYTerminal, A) at ./show.jl:1432                                                                                                                                                                                                                                       
 in writemime(Base.Multimedia.#writemime, Base.Terminals.TTYTerminal, MIME{symbol(&quot;text/plain&quot;)}, A) at ./replutil.jl:4                                                                                                                                                                                                   
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, MIME{symbol(&quot;text/plain&quot;)}, Any) at ./REPL.jl:114                                                                                                                                                                                    
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Any) at ./REPL.jl:117                                                                                                                                                                                                                
 [inlined code] from ./multimedia.jl:151                                                                                                                                                                                                                                                                                  
 in display(Base.Multimedia.#display, Any) at ./multimedia.jl:163                                                                                                                                                                                                                                                         
 in print_response(Base.REPL.#print_response, Base.Terminals.TTYTerminal, Any, Void, Bool, Bool, Void) at ./REPL.jl:134                                                                                                                                                                                                   
 in print_response(Base.REPL.#print_response, Base.REPL.LineEditREPL, Any, Void, Bool, Bool) at ./REPL.jl:121                                                                                                                                                                                                             
 in #18(Base.REPL.##18#19{Bool,Base.#parse_input_line,Base.REPL.LineEditREPL,Base.LineEdit.Prompt}, Base.LineEdit.MIState, Base.AbstractIOBuffer{Array{UInt8,1}}, Bool) at ./REPL.jl:626                                                                                                                                  
 in run_interface at ./LineEdit.jl:1611                                                                                                                                                                                                                                                                                   
 in run_frontend at ./REPL.jl:859                                                                                                                                                                                                                                                                                         
 in run_repl(Base.REPL.#run_repl, Base.REPL.LineEditREPL, Base.##479#480) at ./REPL.jl:167                                                                                                                                                                                                                                
 in _start at ./client.jl:342                                                                                                                                                                                                                                                                                             

julia&gt; convert(A, 0.1, [0.1])                                                                                                                                                                                                                                                                                             
ERROR: MethodError: `convert` has no method matching convert(::Type{A}, ::Float64, ::Array{Float64,1})                                                                                                                                                                                                                    
This may have arisen from a call to the constructor A(...),                                                                                                                                                                                                                                                               
since type constructors fall back to convert methods.                                                                                                                                                                                                                                                                     
Closest candidates are:                                                                                                                                                                                                                                                                                                   
  convert{F}(::Type{A}, ::F)                                                                                                                                                                                                                                                                                              
  convert{F}(::Type{A}, ::F, ::Union{Array{F,1},F})
  (::Type{BoundsError})(::ANY, ::ANY)
  ...                                                                                                                                                                                                                                                                                                                     
 in eval at ./boot.jl:267                                                                                                                                                                                                                                                                                                 "><pre class="notranslate"><code class="notranslate">julia&gt; convert(A, 0.1)                                                                                                                                                                                                                                                                                                    
A(Error showing value of type A:                                                                                                                                                                                                                                                                                          
ERROR: MethodError: `one` has no method matching one(::Type{A})                                                                                                                                                                                                                                                           
 [inlined code] from ./none:1                                                                                                                                                                                                                                                                                             
 in Type(Type{Pair{A,B}}, Symbol, A) at ./operators.jl:507                                                                                                                                                                                                                                                                
 in show_default(Base.#show_default, IOContext{Base.Terminals.TTYTerminal}, Any) at ./show.jl:80                                                                                                                                                                                                                          
 [inlined code] from ./show.jl:73                                                                                                                                                                                                                                                                                         
 in showcompact(Base.#showcompact, Base.Terminals.TTYTerminal, A) at ./show.jl:1432                                                                                                                                                                                                                                       
 in writemime(Base.Multimedia.#writemime, Base.Terminals.TTYTerminal, MIME{symbol("text/plain")}, A) at ./replutil.jl:4                                                                                                                                                                                                   
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, MIME{symbol("text/plain")}, Any) at ./REPL.jl:114                                                                                                                                                                                    
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Any) at ./REPL.jl:117                                                                                                                                                                                                                
 [inlined code] from ./multimedia.jl:151                                                                                                                                                                                                                                                                                  
 in display(Base.Multimedia.#display, Any) at ./multimedia.jl:163                                                                                                                                                                                                                                                         
 in print_response(Base.REPL.#print_response, Base.Terminals.TTYTerminal, Any, Void, Bool, Bool, Void) at ./REPL.jl:134                                                                                                                                                                                                   
 in print_response(Base.REPL.#print_response, Base.REPL.LineEditREPL, Any, Void, Bool, Bool) at ./REPL.jl:121                                                                                                                                                                                                             
 in #18(Base.REPL.##18#19{Bool,Base.#parse_input_line,Base.REPL.LineEditREPL,Base.LineEdit.Prompt}, Base.LineEdit.MIState, Base.AbstractIOBuffer{Array{UInt8,1}}, Bool) at ./REPL.jl:626                                                                                                                                  
 in run_interface at ./LineEdit.jl:1611                                                                                                                                                                                                                                                                                   
 in run_frontend at ./REPL.jl:859                                                                                                                                                                                                                                                                                         
 in run_repl(Base.REPL.#run_repl, Base.REPL.LineEditREPL, Base.##479#480) at ./REPL.jl:167                                                                                                                                                                                                                                
 in _start at ./client.jl:342                                                                                                                                                                                                                                                                                             

julia&gt; convert(A, 0.1, 0.1)                                                                                                                                                                                                                                                                                               
A(Error showing value of type A:                                                                                                                                                                                                                                                                                          
ERROR: MethodError: `one` has no method matching one(::Type{A})                                                                                                                                                                                                                                                           
 [inlined code] from ./none:1                                                                                                                                                                                                                                                                                             
 in Type(Type{Pair{A,B}}, Symbol, A) at ./operators.jl:507                                                                                                                                                                                                                                                                
 in show_default(Base.#show_default, IOContext{Base.Terminals.TTYTerminal}, Any) at ./show.jl:80                                                                                                                                                                                                                          
 [inlined code] from ./show.jl:73                                                                                                                                                                                                                                                                                         
 in showcompact(Base.#showcompact, Base.Terminals.TTYTerminal, A) at ./show.jl:1432                                                                                                                                                                                                                                       
 in writemime(Base.Multimedia.#writemime, Base.Terminals.TTYTerminal, MIME{symbol("text/plain")}, A) at ./replutil.jl:4                                                                                                                                                                                                   
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, MIME{symbol("text/plain")}, Any) at ./REPL.jl:114                                                                                                                                                                                    
 [inlined code] from ./expr.jl:8                                                                                                                                                                                                                                                                                          
 in display(Base.Multimedia.#display, Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, Any) at ./REPL.jl:117                                                                                                                                                                                                                
 [inlined code] from ./multimedia.jl:151                                                                                                                                                                                                                                                                                  
 in display(Base.Multimedia.#display, Any) at ./multimedia.jl:163                                                                                                                                                                                                                                                         
 in print_response(Base.REPL.#print_response, Base.Terminals.TTYTerminal, Any, Void, Bool, Bool, Void) at ./REPL.jl:134                                                                                                                                                                                                   
 in print_response(Base.REPL.#print_response, Base.REPL.LineEditREPL, Any, Void, Bool, Bool) at ./REPL.jl:121                                                                                                                                                                                                             
 in #18(Base.REPL.##18#19{Bool,Base.#parse_input_line,Base.REPL.LineEditREPL,Base.LineEdit.Prompt}, Base.LineEdit.MIState, Base.AbstractIOBuffer{Array{UInt8,1}}, Bool) at ./REPL.jl:626                                                                                                                                  
 in run_interface at ./LineEdit.jl:1611                                                                                                                                                                                                                                                                                   
 in run_frontend at ./REPL.jl:859                                                                                                                                                                                                                                                                                         
 in run_repl(Base.REPL.#run_repl, Base.REPL.LineEditREPL, Base.##479#480) at ./REPL.jl:167                                                                                                                                                                                                                                
 in _start at ./client.jl:342                                                                                                                                                                                                                                                                                             

julia&gt; convert(A, 0.1, [0.1])                                                                                                                                                                                                                                                                                             
ERROR: MethodError: `convert` has no method matching convert(::Type{A}, ::Float64, ::Array{Float64,1})                                                                                                                                                                                                                    
This may have arisen from a call to the constructor A(...),                                                                                                                                                                                                                                                               
since type constructors fall back to convert methods.                                                                                                                                                                                                                                                                     
Closest candidates are:                                                                                                                                                                                                                                                                                                   
  convert{F}(::Type{A}, ::F)                                                                                                                                                                                                                                                                                              
  convert{F}(::Type{A}, ::F, ::Union{Array{F,1},F})
  (::Type{BoundsError})(::ANY, ::ANY)
  ...                                                                                                                                                                                                                                                                                                                     
 in eval at ./boot.jl:267                                                                                                                                                                                                                                                                                                 
</code></pre></div>
<p dir="auto">This works:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; f(x::Int; y::Union(Symbol, Int)=:foo) = println(y)
# methods for generic function f
f(x::Int64) at none:1

julia&gt; f(1)
foo

julia&gt; f(1, y=:bar)
bar

julia&gt; f(1, y=3)
3"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">f</span>(x<span class="pl-k">::</span><span class="pl-c1">Int</span>; y<span class="pl-k">::</span><span class="pl-c1">Union(Symbol, Int)</span><span class="pl-k">=</span><span class="pl-c1">:foo</span>) <span class="pl-k">=</span> <span class="pl-c1">println</span>(y)
<span class="pl-c"><span class="pl-c">#</span> methods for generic function f</span>
<span class="pl-c1">f</span>(x<span class="pl-k">::</span><span class="pl-c1">Int64</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">f</span>(<span class="pl-c1">1</span>)
foo

julia<span class="pl-k">&gt;</span> <span class="pl-c1">f</span>(<span class="pl-c1">1</span>, y<span class="pl-k">=</span><span class="pl-c1">:bar</span>)
bar

julia<span class="pl-k">&gt;</span> <span class="pl-c1">f</span>(<span class="pl-c1">1</span>, y<span class="pl-k">=</span><span class="pl-c1">3</span>)
<span class="pl-c1">3</span></pre></div>
<p dir="auto">A parametric version instead fails with a cryptic message:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; g{T}(x::T; y::Union(Symbol, T)=:foo) = println(y)
# methods for generic function g
g{T}(x::T) at none:1

julia&gt; g(1)
ERROR: no method g#g2(Symbol,Int64)

julia&gt; g(1, y=:bar)
ERROR: no method g#g2(Symbol,Int64)

julia&gt; g(1, y=3)
3"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">g</span><span class="pl-c1">{T}</span>(x<span class="pl-k">::</span><span class="pl-c1">T</span>; y<span class="pl-k">::</span><span class="pl-c1">Union(Symbol, T)</span><span class="pl-k">=</span><span class="pl-c1">:foo</span>) <span class="pl-k">=</span> <span class="pl-c1">println</span>(y)
<span class="pl-c"><span class="pl-c">#</span> methods for generic function g</span>
<span class="pl-c1">g</span><span class="pl-c1">{T}</span>(x<span class="pl-k">::</span><span class="pl-c1">T</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">g</span>(<span class="pl-c1">1</span>)
ERROR<span class="pl-k">:</span> no method g<span class="pl-c"><span class="pl-c">#</span>g2(Symbol,Int64)</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">g</span>(<span class="pl-c1">1</span>, y<span class="pl-k">=</span><span class="pl-c1">:bar</span>)
ERROR<span class="pl-k">:</span> no method g<span class="pl-c"><span class="pl-c">#</span>g2(Symbol,Int64)</span>

julia<span class="pl-k">&gt;</span> <span class="pl-c1">g</span>(<span class="pl-c1">1</span>, y<span class="pl-k">=</span><span class="pl-c1">3</span>)
<span class="pl-c1">3</span></pre></div>
<p dir="auto">Possibly related, this should be an error but less cryptic and preferrably when the function is defined rather than used.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; h(x::Int; y::Int=0.0) = println(y)
# methods for generic function h
h(x::Int64) at none:1

julia&gt; h(1)
ERROR: no method h#g3(Float64,Int64)"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-en">h</span>(x<span class="pl-k">::</span><span class="pl-c1">Int</span>; y<span class="pl-k">::</span><span class="pl-c1">Int</span><span class="pl-k">=</span><span class="pl-c1">0.0</span>) <span class="pl-k">=</span> <span class="pl-c1">println</span>(y)
<span class="pl-c"><span class="pl-c">#</span> methods for generic function h</span>
<span class="pl-c1">h</span>(x<span class="pl-k">::</span><span class="pl-c1">Int64</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">h</span>(<span class="pl-c1">1</span>)
ERROR<span class="pl-k">:</span> no method h<span class="pl-c"><span class="pl-c">#</span>g3(Float64,Int64)</span></pre></div>