Skip to content

Stack level too deep on self referential constant alias #3798

@pkondzior

Description

@pkondzior

Description

Self referential Constant alias are causing SystemStackError

Ruby LSP Information

Following code snippet is going to cause stack level too deep

Reproduction steps

  1. Open VS Code editor
  2. Create test.rb with following content
module RealClass
  CONSTANT = {}
end

module Foo
  SomeClass = ::SomeClass
  RealClass = ::RealClass

  UNRESOLVED = SomeClass::CONSTANT
  CONSTANT = RealClass::CONSTANT
end


RealClass
Foo::UNRESOLVED
  1. Hoover onto Foo::UNRESOLVED
  2. Go to Output, select Ruby LSP and observer there is SystemStackError exception:
2025-10-27 12:09:38.460 [info] (test) #<Thread:0x00000001205de6e0 /Users/pkondzior/Projects/ruby-lsp/vendor/bundle/ruby/3.4.0/bundler/gems/ruby-lsp-5333bb8d45ea/lib/ruby_lsp/base_server.rb:155 run> terminated with exception (report_on_exception is true):

2025-10-27 12:09:38.468 [info] (test) /Users/pkondzior/Projects/ruby-lsp/vendor/bundle/ruby/3.4.0/bundler/gems/ruby-lsp-5333bb8d45ea/lib/ruby_indexer/lib/ruby_indexer/index.rb:424:in 'Integer#downto': stack level too deep (SystemStackError

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions