Skip to content

fix(ruby): a call on a namespaced class links its caller to the class (#2503) - #2509

Closed
drakeo338 wants to merge 2 commits into
colbymchenry:mainfrom
drakeo338:claude/2503-fix
Closed

drakeo338 wants to merge 2 commits into
colbymchenry:mainfrom
drakeo338:claude/2503-fix

Conversation

@drakeo338

Copy link
Copy Markdown
Contributor

Fixes #2503.

Problem

Billing::ChargeCard.call recorded no references edge to Billing::ChargeCard, so a class used only through namespaced class-method calls had no callers. Only a bare constant receiver got one (#1110).

Fix

A scope_resolution receiver whose last segment is capitalized now emits a references ref under its qualified name, leading :: dropped. So Users::Create.call and Users::Create&.call reach Users::Create, not a Billing::Create of the same name. A relative Deep::Op.call inside module Svc reaches Svc::Deep::Op, and ActiveRecord::Base never reaches a project Base. The kernel (ruby.rs) and wasm emit the same refs, ::Foo.call included.

Validation

  • __tests__/ruby-namespaced-receiver.test.ts: 5 cases, each on kernel and wasm, plus a kernel-parity case for these receiver shapes.
  • On main, 8 of the 11 fail. Full suite (kernel rebuilt, CODEGRAPH_KERNEL_EXPECT=1): 6,991 passed, 0 failed. tsc clean.

Agent-assisted: written with Claude Code.

🤖 Generated with Claude Code

…colbymchenry#2503)

`ChargeCard.call` records a references edge from the caller to the
class, but `Billing::ChargeCard.call` did not: only a bare `constant`
receiver got one, so a class used only through namespaced class-method
calls looked like it had no dependents.

A `scope_resolution` receiver whose last segment is capitalized now
emits a references ref too, under its qualified name with a leading
`::` dropped. The resolver already maps that to the right class, so
`Users::Create.call` reaches `Users::Create` rather than a
`Billing::Create`, and `Deep::Op.call` written inside `module Svc`
reaches `Svc::Deep::Op`. The native kernel (ruby.rs) makes the same
change, so both backends emit identical refs, `::Foo.call` included.
@colbymchenry

Copy link
Copy Markdown
Owner

Thank you for the PR and its five-case test, @drakeo338! The same fix landed on main as #2827: a namespaced receiver like Billing::ChargeCard.call is now looked up the way Ruby does it, from the enclosing namespaces outward, so Users::Create and Billing::Create stay apart and ActiveRecord::Base never reaches a project Base. Its changelog entry credits your pull request. It ships in the next release, and your test passes on today's main in both engines. Closing as superseded. Thanks again!

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.

Ruby: namespaced-constant receivers (A::B.call) get no references edge, so the class has 0 callers

2 participants