Skip to content

Compare the Pattern DSL prefix with the module name - #4244

Merged
kddnewton merged 1 commit into
ruby:mainfrom
mame:pattern-module-name
Oct 7, 2026
Merged

kddnewton merged 1 commit into
ruby:mainfrom
mame:pattern-module-name

Conversation

@mame

@mame mame commented Oct 7, 2026

Copy link
Copy Markdown
Member

Prism::Pattern accepts Prism::CallNode by comparing the parent constant with the literal string "Prism". This compares it with Prism.name instead, and also accepts a constant path as the parent, so that the same code works when the library is loaded under another namespace. For Prism itself, the behavior does not change.

Background: in https://bugs.ruby-lang.org/issues/22379, ruby/ruby is considering building prism into the interpreter as Ruby::Prism, by rewriting the namespace when syncing from this repository (PoC: ruby/ruby#19248). This literal was the only place that did not follow the rewrite. There, the pattern is written as Ruby::Prism::CallNode (or just CallNode).

The pattern compiler accepted `Prism::CallNode` by comparing the parent
constant with the literal string "Prism".  Compare it with `Prism.name`
instead, and also accept a constant path as the parent, so that the
same code works when the library is loaded under another namespace.

ruby/ruby is considering building prism into the interpreter as
`Ruby::Prism` by rewriting the namespace when syncing from this
repository (https://bugs.ruby-lang.org/issues/22379).  The literal
"Prism" here was the only place that did not follow the rewrite.  For
`Prism` itself, the behavior does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kddnewton
kddnewton merged commit 91df23f into ruby:main Oct 7, 2026
101 checks passed
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.

2 participants