Skip to content

Local variable assignment being incorrectly recognised as debugging commands #803

Closed

Description

@st0012

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

Activity

  1. added
    bug
    on Dec 5, 2023
  2. tompng commented on Apr 4, 2024

    @tompng
    Member

    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.

  3. tompng commented on Jan 3, 2025

    @tompng
    Member

    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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions