Closed keelzebub closed 5 years ago
Thanks, @beaksandclaws!
I was able to reproduce the error with this example:
class Thing
def foo
return if true
end
end
Thing.new.foo.bar
Hovering over bar
in the last line triggers the error.
The problem is in a new feature that attempts to infer a method's type from its return nodes (https://github.com/castwide/solargraph/issues/105). Fortunately, it should be an easy fix. I'll handle it in a patch release of the gem ASAP.
Fix released in gem version 0.29.4.
Receiving the following error:
[Error - 1:29:34 PM] Request textDocument/hover failed. Message: [NoMethodError] undefined method 'type' for nil:NilClass Code: -32603
I'm running gem version 0.29.1 (although it also happens in 0.29.3) on Ruby 2.2.1, and I'm not exactly sure what I'm specifically hovering over that produces that message. In the Developer Tools console I see the following messages:
[Extension Host] undefined method `type' for nil:NilClass (at Socket.__dirname.start.Promise.child.stderr.on (/Users/beaksandclaws/Documents/Application Preferences/VSCode/.vscode-insiders/extensions/castwide.solargraph-0.18.0/node_modules/solargraph-utils/out/SocketProvider.js:15:25))
followed by:
[Extension Host] /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:173:in `block in reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:179:in `block in reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:179:in `block in reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:179:in `block in reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:179:in `block in reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:172:in `reduce_to_value_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:127:in `get_return_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/node_methods.rb:113:in `returns_from' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/pin/method.rb:128:in `infer_from_return_nodes' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/pin/method.rb:95:in `infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:69:in `block in infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:68:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:68:in `infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/pin/base_variable.rb:49:in `infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:110:in `block in infer_first_defined' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:109:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:109:in `infer_first_defined' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:52:in `block in define' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:48:in `each' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:48:in `define' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:67:in `infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/pin/base_variable.rb:49:in `infer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain/call.rb:58:in `block in inferred_pins' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain/call.rb:43:in `map' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain/call.rb:43:in `inferred_pins' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain/call.rb:18:in `resolve' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source/chain.rb:56:in `define' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/source_map/clip.rb:17:in `define' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/library.rb:140:in `definitions_at' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/host.rb:367:in `definitions_at' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/message/text_document/hover.rb:11:in `process' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/host.rb:75:in `start' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/socket.rb:19:in `process' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/socket.rb:13:in `block in post_init' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/data_reader.rb:53:in `call' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/data_reader.rb:53:in `parse_message_from_buffer' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/data_reader.rb:31:in `block in receive' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/data_reader.rb:26:in `each_char' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/data_reader.rb:26:in `receive' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/language_server/transport/socket.rb:27:in `receive_data' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run_machine' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/eventmachine-1.2.5/lib/eventmachine.rb:194:in `run' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/lib/solargraph/shell.rb:25:in `socket' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/thor-0.19.4/lib/thor/command.rb:27:in `run' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/thor-0.19.4/lib/thor/base.rb:444:in `start' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/gems/solargraph-0.29.1/bin/solargraph:5:in `<top (required)>' (at Socket.__dirname.start.Promise.child.stderr.on (/Users/beaksandclaws/Documents/Application Preferences/VSCode/.vscode-insiders/extensions/castwide.solargraph-0.18.0/node_modules/solargraph-utils/out/SocketProvider.js:15:25))
followed by:
/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:303 [Extension Host] /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/bin/solargraph:23:in `load' /Users/beaksandclaws/.rbenv/versions/2.2.1/gemsets/my_project/bin/solargraph:23:in `<main>' (at Socket.__dirname.start.Promise.child.stderr.on (/Users/beaksandclaws/Documents/Application Preferences/VSCode/.vscode-insiders/extensions/castwide.solargraph-0.18.0/node_modules/solargraph-utils/out/SocketProvider.js:15:25))
and finally:
/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:5721 [castwide.solargraph]Cannot read property 'contents' of null
TypeError: Cannot read property 'contents' of null at middleware.provideHover.promise.then (/Users/kellen/Documents/Application Preferences/VSCode/.vscode-insiders/extensions/castwide.solargraph-0.18.0/out/src/language-client.js:29:27) at <anonymous>
I hope that's enough information! I love the plugin, so much nicer than what I was using before.