Skip to content

Conversation

oscardssmith
Copy link
Member

@oscardssmith oscardssmith commented May 12, 2025

fixes #1017
This also removes NoMethodsError, TooManyArgumentsError, and TooFewArgumentsError and fixes inference for some *Function constructors`

hasmethod(f, ntuple(_->Any, outofplace_param_number)) && return false
hasmethod(f, ntuple(_->Any, inplace_param_number)) && return true
end
throw(FunctionArgumentsError(fname, f))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message loses a lot of information. Can we in the error path do a method check and throw the more informative error message?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the better method is to just put the expected nargs in the exception and then we can make the exception printing in charge of that logic. That way none of the complicated bits are in the main function.

@oscardssmith
Copy link
Member Author

I just remembered the tricky part here. This query isn't quite right (see JuliaLang/julia#56279 for details):

julia> f(a::Int, b) = true
f (generic function with 1 method)

julia> hasmethod(f, (Any, Any))
false # because !(Any<:Int)

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

Successfully merging this pull request may close these issues.

isinplace fails to infer on v1.10+
2 participants