Fix `exit` after previous syntax error in `exit` command. #550

Merged
merged 1 commit into from Apr 25, 2012

Conversation

Projects
None yet
2 participants
@rmascarenhas
Contributor

rmascarenhas commented Apr 25, 2012

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: <main>: 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 evaled inline with a throw statement. If there is an exception while evaling, we won't go back to the correspondent catch.

Now the user-given value is first evaled, 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.

Renato Mascarenhas
Fix `exit` after previous syntax error in `exit` command.
Before this commit, the binding stack was cleared before evaluating
the user-given value for the `exit` command. If a syntax error happened
when `eval`ing it, the program would still be running with no elements
in the binding stack, causing next calls of `exit` to fail.

banister added a commit that referenced this pull request Apr 25, 2012

version 0.9.9.4 bugfix release
Fixes `undefined method `winsize' for #<IO:<STDOUT>>` error (#549), and exit breakage on syntax error (#550).

@banister banister merged commit 1dc68c9 into pry:master Apr 25, 2012

@banister

This comment has been minimized.

Show comment Hide comment
@banister

banister Apr 25, 2012

Owner

nice catch, thanks

Owner

banister commented Apr 25, 2012

nice catch, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment