Skip to content

todo_spec fails on Rails 8.0: unresolved constant names have reversed nesting #2593

@amomchilov

Description

@amomchilov

Summary

todo_spec.rb:34 ("it creates a list of all unresolved constants") fails on all Rails 8.0 CI matrix jobs (Ruby 3.2, 3.3, 3.4, 4.0), but passes on Rails current (8.1) and main.

Observed on PR #2588, commit 13303b7.

Failure

Sorbet's --print=missing-constants outputs different fully-qualified names on Rails 8.0 vs 8.1+:

 module ::Undef1; end
-module ::Undef1::Undef3; end
-module ::Undef2::Undef4; end
+module ::Undef3::Undef1; end
+module ::Undef4::Undef2; end
 module Foo::Bar::Undef6; end
 module Foo::Bar::Undef7; end
 module Foo::Undef2; end

The namespace nesting is reversed — ::Undef1::Undef3 becomes ::Undef3::Undef1.

Reproducing

The test input is:

::Undef1::Undef3.foo
Undef2::Undef4.bar

On Rails 8.0, Sorbet resolves these constant references differently than on 8.1+, presumably due to a difference in Rails' constant autoloading or namespace setup that affects Sorbet's resolver.

CI matrix

Ruby Rails 8.0 Rails current (8.1) Rails main
3.2 failure success -
3.3 failure success success
3.4 failure success success
4.0 failure success success
head success success success

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions