Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No implizit conversion of default arguments #21128

Closed
Jackels opened this issue Mar 21, 2017 · 2 comments
Closed

No implizit conversion of default arguments #21128

Jackels opened this issue Mar 21, 2017 · 2 comments

Comments

@Jackels
Copy link

Jackels commented Mar 21, 2017

I had this problem today

function stupid(foo::Array{Float64, 1}, index::UInt64 = 1)
end

stupid([1.0])

This is something that should run, but when you try it gives you a very confusing error.

ERROR: LoadError: MethodError: no method matching stupid(::Array{Float64,1}, ::Int64)
Closest candidates are:
  stupid(::Array{Float64,1}, !Matched::UInt64) at ~\julia-experiments\definitions.jl:2
  stupid(::Array{Float64,1}) at C:\Users\bossert\julia-experiments\definitions.jl:2
 in stupid(::Array{Float64,1}) at C:\Users\bossert\julia-experiments\definitions.jl:2
 in include_from_node1(::String) at .\loading.jl:488
 in process_options(::Base.JLOptions) at .\client.jl:265
 in _start() at .\client.jl:321

This is telling me nothing useful or comprehensible. It does not find a method that matches, but the first candidate it finds matches everything? What does the '!' mean before Matched?

After toying around in frustration i found the solution to my problem

function stupid(foo::Array{Float64, 1}, index::UInt64 = UInt64(1))
end

stupid([1.0])

Next time please either tell me that my signature makes no sense ( which is btw. not on line 2 but on line 1 ) or do the conversion yourself.

@KristofferC
Copy link
Sponsor Member

!Matched means not matched. If you have a terminal that supports color this is showed in red.

@StefanKarpinski
Copy link
Sponsor Member

Dup of #7357

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants