Skip to content
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

Interpreter: handle escaping exceptions in pry #12211

Merged
merged 1 commit into from Jul 6, 2022

Conversation

asterite
Copy link
Member

@asterite asterite commented Jul 6, 2022

Fixes #12210

Before:

✗ crystal i foo.cr
From: foo.cr:6:6 <Program>#foo.cr:

    1: def foo
    2:   raise "OH NO!"
    3: end
    4:
    5: debugger
 => 6: puts "Hello world!"

pry> foo
 (Crystal::Repl::EscapingException)
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'raise<Crystal::Repl::EscapingException>:NoReturn'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'Crystal::Repl::Interpreter#interpret<Crystal::ASTNode+, Crystal::Type+>:Crystal::Repl::Value'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'Crystal::Repl::Interpreter#pry<Pointer(UInt8), Crystal::Repl::CompiledInstructions, Pointer(UInt8), Pointer(UInt8)>:(Pointer(UInt8) | Nil)'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'Crystal::Repl::Interpreter#interpret<Crystal::ASTNode+, Crystal::Type+>:Crystal::Repl::Value'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'Crystal::Repl#interpret_and_exit_on_error<Crystal::Expressions>:Crystal::Repl::Value'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'Crystal::Command#repl:(Crystal::Repl::Value | Nil)'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in '__crystal_main'
  from /opt/homebrew/Cellar/crystal/1.4.1_2/libexec/crystal in 'main'

After:

$ bin/crystal i foo.cr
Using compiled compiler at .build/crystal
From: foo.cr:6:6 <Program>#foo.cr:

    1: def foo
    2:   raise "OH NO!"
    3: end
    4:
    5: debugger
 => 6: puts "Hello world!"

pry> foo
Unhandled exception: OH NO! (Exception)
  from foo.cr:2:3 in 'foo'
  from :1:1 in 'foo.cr'

@straight-shoota straight-shoota added this to the 1.5.0 milestone Jul 6, 2022
@asterite
Copy link
Member Author

asterite commented Jul 6, 2022

Yay! Thank you for adding this to 1.5.0 🙏

@beta-ziliani beta-ziliani merged commit d9660c1 into master Jul 6, 2022
@straight-shoota straight-shoota deleted the bug/interpreter-pry-escaping-exception branch July 6, 2022 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interpreter: improve runtime exception reporting in pry session
4 participants