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

Local variable assignment being incorrectly recognised as debugging commands #803

Closed
st0012 opened this issue Dec 5, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@st0012
Copy link
Member

st0012 commented Dec 5, 2023

Description

When assigning a local variable which's name is the same one of the debugging commands (e.g. info), it'd be treated as the command call instead of a local assignment:

irb(main):001> info = 123
`debug` command is only available when IRB is started with binding.irb
=> nil
@tompng
Copy link
Member

tompng commented Apr 4, 2024

We can check command-like assignment by regexp like /\A#{COMMAND_NAME} (=|\+=|-=|\*=|...)/

info = 123
info += 1
info <<= 1

Now, using local variable info seems hard because the code below will be treated as command

info + 1
info << 1
info > 42

But maybe this can be solved by extending the command-method override policy (NO_OVERRIDE OVERRIDE_ALL OVERRIDE_PRIVATE_ONLY) to also check local variables existence.

@tompng
Copy link
Member

tompng commented Jan 3, 2025

Fixed by #961

irb(main):001> info
Debugging commands are only available when IRB is started with binding.irb
irb(main):002> info = 123
=> 123
irb(main):003> info
=> 123

The problem is not solved in irb:rdbg mode but it's an issue of ruby/debug ruby/debug#1108

irb:rdbg(main):003> info = 123
unrecognized argument for info command: = 123

@tompng tompng closed this as completed Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants