irb icon indicating copy to clipboard operation
irb copied to clipboard

Local variable assignment being incorrectly recognised as debugging commands

Open st0012 opened this issue 1 year ago • 1 comments

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

st0012 avatar Dec 05 '23 20:12 st0012

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 avatar Apr 04 '24 12:04 tompng