Skip to content

Fix infinite loop in define_all for RBS include with same-name nested constant#437

Merged
mame merged 1 commit intoruby:masterfrom
sinsoku:fix-rbs-include-infinite-loop
Apr 16, 2026
Merged

Fix infinite loop in define_all for RBS include with same-name nested constant#437
mame merged 1 commit intoruby:masterfrom
sinsoku:fix-rbs-include-infinite-loop

Conversation

@sinsoku
Copy link
Copy Markdown
Contributor

@sinsoku sinsoku commented Apr 14, 2026

When module X contains class X, resolving include X in RBS
searched the ancestor chain (search_ancestors=true), which caused the
resolved constant to flip between X (module) and X::X (class) on
every re-evaluation, looping define_all forever.

The .rb side already avoids this via use_strict_const_scope in
IncludeMetaNode. Apply the same strict_const_scope=true to
SigIncludeNode and SigPrependNode so that include/prepend targets
are resolved through lexical scope only.

fixes #431

…ed constant

When `module X` contains `class X`, resolving `include X` in RBS
searched the ancestor chain (`search_ancestors=true`), which caused the
resolved constant to flip between X (module) and X::X (class) on
every re-evaluation, looping `define_all` forever.

The .rb side already avoids this via `use_strict_const_scope` in
IncludeMetaNode. Apply the same `strict_const_scope=true` to
SigIncludeNode and SigPrependNode so that include/prepend targets
are resolved through lexical scope only.
Copy link
Copy Markdown
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mame mame merged commit 6282802 into ruby:master Apr 16, 2026
6 checks passed
@sinsoku sinsoku deleted the fix-rbs-include-infinite-loop branch April 16, 2026 15:03
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.

http-2 signature causes infinite loop

2 participants