Giter Club home page Giter Club logo

Comments (8)

andyw8 avatar andyw8 commented on August 23, 2024

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.

vinistock avatar vinistock commented on August 23, 2024

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.

zachahn-gusto avatar zachahn-gusto commented on August 23, 2024

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.

andyw8 avatar andyw8 commented on August 23, 2024

@zachahn-gusto are you on the latest server gem? This does not error for me.

from ruby-lsp.

zachahn-gusto avatar zachahn-gusto commented on August 23, 2024

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.

zachahn-gusto avatar zachahn-gusto commented on August 23, 2024

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.

vinistock avatar vinistock commented on August 23, 2024

Ah, that's another part of the bug we missed indeed. I'm cutting a PR for that.

from ruby-lsp.

vinistock avatar vinistock commented on August 23, 2024

#2471

from ruby-lsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.