debug
debug copied to clipboard
Allow assigning to local variable conflicting with command name
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 https://github.com/ruby/irb/pull/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