pry/pry — pull request #550 by rmascarenhas (2012-04-25 20:55:51+00:00)
Title: Fix `exit` after previous syntax error in `exit` command.

I accidentally tried to assign a value to an "exit" variable, forgetting that it was actually a pry command. As a result, later calls to exit don't work:

[1] pry(main)> exit = 0
SyntaxError:

: syntax error, unexpected '='
from /.../pry/lib/pry/default_commands/navigating_pry.rb:48:in `eval'
[2] pry(nil):-1> exit
NoMethodError: private method `eval' called for nil:NilClass
from /.../pry/lib/pry/default_commands/navigating_pry.rb:83:in `process_pop_and_return'
[3] pry(nil):-1>

We can even see a `-1` level at the prompt.

This happened because the user-given value passed to exit was `eval`ed inline with a `throw` statement. If there is an exception while `eval`ing, we won't go back to the correspondent `catch`.

Now the user-given value is first `eval`ed, and then later the binding stack is cleared and we do the proper `throw`.

If there is anything that could be improved, please let me know.