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

Obscure error with incorrect keyword argument defaults #13599

Open
c42f opened this issue Oct 14, 2015 · 3 comments
Open

Obscure error with incorrect keyword argument defaults #13599

c42f opened this issue Oct 14, 2015 · 3 comments
Labels
error handling Handling of exceptions by Julia or the user keyword arguments f(x; keyword=arguments)

Comments

@c42f
Copy link
Member

c42f commented Oct 14, 2015

If a keyword argument has a declared type, but the default value is of a different type, the error message is confusing:

julia> f(; a::Float64=1) = a
f (generic function with 1 method)

julia> f()
ERROR: MethodError: `__f#0__` has no method matching __f#0__(::Int64)

It would be nice to have a more comprehensible error message here. (Could this error even be caught during type inference? It seems like all the information should be there.)

@c42f
Copy link
Member Author

c42f commented Oct 14, 2015

Side note - I tried using code_typed to understand what is produced here when a is supplied vs defaulted, but I don't see a way to specify keyword arguments to code_typed. Is this possible?

@tkelman tkelman added the error handling Handling of exceptions by Julia or the user label Oct 14, 2015
@mauro3
Copy link
Contributor

mauro3 commented Jun 24, 2016

Struggling with this error message over in ODE.jl: SciML/ODE.jl#49 (comment)

@JeffBezanson
Copy link
Member

Very similar to #16490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user keyword arguments f(x; keyword=arguments)
Projects
None yet
Development

No branches or pull requests

4 participants