Skip to content

Improve MethodError message for anonymous functions #57340

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

Merged
merged 6 commits into from
Feb 26, 2025

Conversation

Bumblebee00
Copy link
Contributor

If a MethodError arises on a anonyomous function, the words "anonymous function" are printed in the error like so:

g=(x,y)->x+y
g(1,2,3)
ERROR: MethodError: no method of the anonymous function var"#5#6" matching (::var"#5#6")(::Int64, ::Int64, ::Int64)
The function `#5` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  (::var"#5#6")(::Any, ::Any)
   @ Main REPL[4]:1

See the original pull request and issue #56325

@nsajko nsajko added the error messages Better, more actionable error messages label Feb 10, 2025
Copy link
Member

@ararslan ararslan left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for the contribution!

@Bumblebee00
Copy link
Contributor Author

will this pr be merged into master sooner or later? just asking bc I am new to julia contributions

@adienes adienes added the merge me PR is reviewed. Merge when all tests are passing label Feb 25, 2025
@inkydragon inkydragon changed the title MethodError prints "anonymous function" for anonymous functions Improve MethodError message for anonymous functions Feb 26, 2025
@inkydragon inkydragon merged commit 66780fd into JuliaLang:master Feb 26, 2025
9 checks passed
@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Feb 26, 2025
@Bumblebee00 Bumblebee00 deleted the MethodError_feature_57319 branch February 26, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Better, more actionable error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants