Skip to content

Support absolute constant paths like class ::Foo - #506

Closed
nbifrye wants to merge 1 commit into
ruby:masterfrom
nbifrye:fix-absolute-constant-path
Closed

nbifrye wants to merge 1 commit into
ruby:masterfrom
nbifrye:fix-absolute-constant-path

Conversation

@nbifrye

@nbifrye nbifrye commented Dec 2, 2026

Copy link
Copy Markdown

Fixes the class ::Foo issue added as a known issue in #505.

TypeProf did not handle constant paths that start with ::. For example, class ::Foo was treated as reopening Object, and it was printed as class < BasicObject. There were two causes:

  • AST.parse_cpath returned before adding the last name of a path that starts with ::. So ::Foo became [] and ::M::Baz became [:Baz]. This also affected class << ::Foo and constant writes
    such as ::X = 1.
  • format_declared_const_path printed a nested path that is not under the enclosing scope as a relative name. So module M; class ::Bar was printed as class Bar inside module M, which means
    M::Bar in RBS. It is now printed as ::Bar.

@nbifrye
nbifrye marked this pull request as draft December 2, 2026 02:59
@nbifrye nbifrye closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant