Comments (8)
I'm still investigating but have narrowed it down to this:
# lib/httplog/adapters/http.rb
module ::HTTP
class Client
define_method request_method do |req, options|
@response = send(orig_request_method, req, options)
end
end
end
from ruby-lsp.
I think there might be multiple layers. The top level reference on the module could be the issue. Maybe we're not deleting that prefix in some operation (since we always store entries without the leading ::
).
But another possible issue might be the fact that we're indexing @response
incorrectly due to the meta-programming. Since it's inside a define_method
call, we're probably considering it as a class instance variable rather than an instance variable - which could also be the source of the problem.
from ruby-lsp.
Hello!
I ran into a very similar error. I think @vinistock's comment is correct, that ::
prefix isn't always being deleted. Here's an example that should break it. Removing the ::
in the code fixed it.
# this errored
module ::Example1
class Example2
class << self
def example3
end
end
end
end
from ruby-lsp.
@zachahn-gusto are you on the latest server gem? This does not error for me.
from ruby-lsp.
Yes I am! 0.17.14. To be honest, I wasn't really able to reproduce this issue consistently. I'll see if I can find a better test case.
from ruby-lsp.
Quick update, I wasn't able to make it crash, but here's a test case that demonstrates what I'm seeing
def test_indexing_singleton
index(<<~RUBY)
module ::Foo
class Bar
class << self
end
end
end
RUBY
# We want to explicitly verify that we didn't introduce the leading `::` by accident, but `Index#[]` deletes the
# prefix when we use `refute_entry`
entries = @index.instance_variable_get(:@entries)
assert_empty(entries.keys.select { _1.start_with?("::") })
end
That fails with this error:
Failure:
RubyIndexer::ClassesAndModulesTest#test_indexing_singleton [~/ruby-lsp/lib/ruby_indexer/test/classes_and_modules_test.rb:601]
Minitest::Assertion: Expected ["::Foo::Bar::<Class:Bar>"]
to be empty.
from ruby-lsp.
Ah, that's another part of the bug we missed indeed. I'm cutting a PR for that.
from ruby-lsp.
from ruby-lsp.
Related Issues (20)
- Wrong syntax highlighting with multiline string
- Unintuitive process for re-enabling VSCode extension after a Ruby update
- Saving is taking forever HOT 9
- "Jump to factory" link in tests HOT 1
- Explore simple type flow analysis
- Ruby environment activation fails in PowerShell HOT 2
- Weird Diagnostics for eruby HOT 6
- Investigate disabling `BUNDLE_BIN` automatically HOT 2
- "Invalid yield" diagnostic in erb HOT 1
- 100% CPU usage HOT 7
- `uninitialized constant Parser (NameError)` HOT 3
- unexpected local variable or method diagnostic in erb when multiple ruby fragments on the same line HOT 5
- Ruby LSP Overrides Token Color Settings HOT 1
- Breadcrumb Navigation and Code Folding Disabled When Ruby LSP Is Enabled HOT 2
- Test issue for GH automation
- Test issue for GH automation (should be assigned) HOT 1
- Add support for semantic tokens delta
- setup_bundler's `rails_app?` incompatible with non-ascii characters HOT 13
- Formatting error: undefined method `value' for an instance of Symbol HOT 12
- Go To Definition is Mapped to CMD + B HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-lsp.