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

break debug command changes ruby behavior #977

Closed
etiennebarrie opened this issue Jun 26, 2024 · 2 comments
Closed

break debug command changes ruby behavior #977

etiennebarrie opened this issue Jun 26, 2024 · 2 comments

Comments

@etiennebarrie
Copy link

Description

When evaluating a Ruby expression that starts with break while not using the debugger, the behavior of the ruby code changes.

$ ruby -e 'p((break :foo while true))'
:foo
$ irb -f --prompt simple
>> break :foo while true
Debugging commands are only available when IRB is started with binding.irb
=> nil

The line evaluates to nil while I would expect to evaluate to :foo like it does without IRB.

Result of irb_info

Ruby version: 3.3.3
IRB version: irb 1.13.2 (2024-06-15)
InputMethod: RelineInputMethod with Reline 0.5.9 and /Users/etienne/.inputrc
Completion: Autocomplete, RegexpCompletor
.irbrc paths: /Users/etienne/.config/irb/irbrc
RUBY_PLATFORM: arm64-darwin23
LC_ALL env: en_US.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

Terminal.app

Setting Files

Disabled using the -f command-line option.

@tompng
Copy link
Member

tompng commented Jun 27, 2024

The confusing => nil part is now hidden in master branch. #972

Break command and ruby expression has a conflict.

# add a breakpoint to file "./while" on line 1
irb(main):001> break while 1

Changing the behavior will also make unexpected result.

irb(main):001> break file.rb 2
#=> SyntaxError, but I expect a message why break command is not available now

I think it is not easy to improve.

@etiennebarrie
Copy link
Author

Thank you.

The confusing => nil part is now hidden in master branch. #972

This has been released in 1.14.0.

I think it is not easy to improve

Indeed. As a workaround, prepending ; makes sure the line is considered as Ruby code.

$ irb -f --simple-prompt
>> break :foo while true
Debugging commands are only available when IRB is started with binding.irb
>> ;break :foo while true
=> :foo

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

No branches or pull requests

2 participants