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

Allow assigning to local variable conflicting with command name #1108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tompng
Copy link
Member

@tompng tompng commented Jul 1, 2024

n = 1 n += 1 n **= 1 n &&= 1 will be a ruby expression, not a shorthand of next command.

(ruby) n = 1
1
(ruby) n += 100
101
(rdbg) p n    # command
=> 101
(rdbg) n    # next command

Background

IRB's command recognization is changed in ruby/irb#961 (merged but not released yet) to fix some reported issues

irb(main):001>measure = Measure.first
=> error
irb(main):002> jobs = Job.where(id: ids)
deprecation message of Multi-irb

The rules are:

  • Multiline input is not a command
  • Assign-like expression is not a command, checked by a simple regexp and String#start_with?
  • If method with the same name as command is defined, follow the method override policy of each command
  • If local variable with the same name as command is defined, it is not a command

This pull request will change debug's command recognizing rule similar to IRB style.

Implementation difference between IRB

Debug does not have the third rule: method override policy. The fourth rule of defined local variables is also dropped.
Command check is called for every keystroke to colorize input and to calculate prompt when used with Reline. Local variable check is too costly in remote debug session for this usage.

# IRB
irb(main):001> help = 1
=> 1
irb(main):002> help + 1
=> 2
irb(main):003> irb_help # help command
# Debug
(ruby) n = 1
1
(rdbg) n + 1 # this will be next command
Unknown option: + 1
(rdbg) p n + 1 # workaround
=> 2

`n = 1` `n += 1` will be a ruby expression, not a shorthand of `next` command.
Copy link

launchable-app bot commented Jul 1, 2024

All Tests passed!

✖️no tests failed ✔️673 tests passed(1 flake)

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

Successfully merging this pull request may close these issues.

1 participant