-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix wrong error message for nil.func() call
#1834
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
Conversation
I find no tests for this in that file. https://github.com/elixir-lang/elixir/blob/master/lib/elixir/test/elixir/exception_test.exs would be a good place to add tests.
I would go with something as |
|
@ericmj Good point.
I will add tests and also use the |
|
@ericmj @josevalim I made the changes
@josevalim what's about this good night. 🌔 |
lib/iex/lib/iex/evaluator.ex
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ericmj and @tonini! I don't think the :no_module is a good approach though because :no_module is still a valid atom name. I think the best to do here is to stop using UndefinedFunctionError and simply return RuntimeError[message: "undefined function #{function}/#{arity}"] (note arity can be a list, so we need to convert it to an integer if so).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:no_module is still a valid atom name
Ok I see what you mean.
I will update the source with using a RuntimeError instead for a review.
Yeah, we are testing exactly the number doesn't change. We have a couple tests like that in the suite. :) |
|
We could probably fix those tests to use some combination of |
|
@josevalim You showed the error message above like : Would you like to change the current message style or leave it as it is? |
|
Let's just show the arity. This error can only happen when the user types |
|
ok. :) — On Fri, Nov 1, 2013 at 11:38 AM, José Valim notifications@github.com
|
|
@josevalim @ericmj Ok I'm done with a first realization, please review and give feedback if needed. ;) |
lib/iex/lib/iex/evaluator.ex
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it can ever not be one of those, so I would get rid of this clause. Everything else is perfect. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you talk about the true -> clause` ?
The expected behavior for `nil.func()` should be:
iex(1)> nil.test()
** (UndefinedFunctionError) undefined function: nil.test/0
nil.test()
Also via cli `elixir -e`:
$ elixir -e 'nil.test()'
** (UndefinedFunctionError) undefined function: nil.test/0
nil.test()
....
Undefined function calls behave like:
iex(1)> hello()
** (RuntimeError) undefined function: hello/0
|
@josevalim The clause is updated. :) |
fix wrong error message for `nil.func()` call
|
❤️ 💚 💙 💛 💜 |
|
Awesome @tonini! |
|
My pleasure! |
The expected behavior for
nil.func()should be:Also via cli
elixir -e:@josevalim as you can see I explicit give an
:no_modulesymbol as argument for the module inside ofnormalize_exception/2function to get around the problem thatnilget in front of every function name inside of theUndefinedFunctionErrorexception.Maybe it's not the nicest solution, I'm open for feedback and ideas. :)
reference: #1823