Skip to content

Debugger raise "NameError" when it hovers the mouse cursor over ".new" in VSCode #460

@ono-max

Description

@ono-max

Your environment

  • ruby -v:
    ruby 2.6.7p197 (2021-04-05 revision 67941) [x86_64-darwin20]

Describe the bug
When it hovers the mouse cursor over ".new", debugger raise "NameError" as follows:

$ exe/rdbg target.rb --open=vscode
DEBUGGER: Debugger can attach via UNIX domain socket (/var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/ruby-debug-sock-501/ruby-debug-naotto-43763)
DEBUGGER: wait for debugger connection...
Launching: code /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/ruby-debug-vscode-20211226-43763-1vukogr/ /var/folders/kv/w1k6nh1x5fl7vx47b2pd005w0000gn/T/ruby-debug-vscode-20211226-43763-1vukogr/README.rb
DEBUGGER: Connected.
["DEBUGGER Exception: /Users/naotto/workspace/debug/lib/debug/thread_client.rb:986",
 #<NameError: wrong constant name Sample.new>,
 ["/Users/naotto/workspace/debug/lib/debug/server_dap.rb:813:in `const_defined?'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:813:in `block (2 levels) in search_const'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:812:in `all?'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:812:in `block in search_const'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:811:in `reverse_each'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:811:in `search_const'",
  "/Users/naotto/workspace/debug/lib/debug/server_dap.rb:749:in `process_dap'",
  "/Users/naotto/workspace/debug/lib/debug/thread_client.rb:975:in `wait_next_action_'",
  "/Users/naotto/workspace/debug/lib/debug/thread_client.rb:676:in `wait_next_action'",
  "/Users/naotto/workspace/debug/lib/debug/thread_client.rb:284:in `suspend'",
  "/Users/naotto/workspace/debug/lib/debug/thread_client.rb:217:in `on_breakpoint'",
  "/Users/naotto/workspace/debug/lib/debug/breakpoint.rb:65:in `suspend'",
  "/Users/naotto/workspace/debug/lib/debug/breakpoint.rb:157:in `block in setup'",
  "target.rb:1:in `<main>'"]]
DEBUGGER: Disconnected.
/Users/naotto/workspace/debug/lib/debug/server_dap.rb:813:in `const_defined?': wrong constant name Sample.new (NameError)
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:813:in `block (2 levels) in search_const'
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:812:in `all?'
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:812:in `block in search_const'
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:811:in `reverse_each'
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:811:in `search_const'
	from /Users/naotto/workspace/debug/lib/debug/server_dap.rb:749:in `process_dap'
	from /Users/naotto/workspace/debug/lib/debug/thread_client.rb:975:in `wait_next_action_'
	from /Users/naotto/workspace/debug/lib/debug/thread_client.rb:676:in `wait_next_action'
	from /Users/naotto/workspace/debug/lib/debug/thread_client.rb:284:in `suspend'
	from /Users/naotto/workspace/debug/lib/debug/thread_client.rb:217:in `on_breakpoint'
	from /Users/naotto/workspace/debug/lib/debug/breakpoint.rb:65:in `suspend'
	from /Users/naotto/workspace/debug/lib/debug/breakpoint.rb:157:in `block in setup'
	from target.rb:1:in `<main>'

To Reproduce

class Sample
  def a
    p :a
  end
end

s = Sample.new
s.a

b = 1
c = 1

Expected behavior
It should not raise an error.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions