Skip to content

fix(ruby): emit inherits edge for class superclass#1535

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/ruby-inheritance
Closed

fix(ruby): emit inherits edge for class superclass#1535
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/ruby-inheritance

Conversation

@Synvoya

@Synvoya Synvoya commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The Ruby extractor silently drops every class inheritance edge. class Dog < Animal produces contains/method/call edges but no inherits edge.

Root cause

Ruby exposes the base class in the superclass field:

class <name=constant, superclass=superclass, body=body_statement>
  superclass -> '<' + constant "Animal"

The inheritance handler in _extract_generic has dedicated branches for java, kotlin, c#, scala, cpp, php, swift, and python — but none for Ruby, so the superclass field is never read.

Fix

Add a Ruby branch that reads the superclass field and emits an inherits edge, handling both forms:

  • bare constant: class Dog < Animal -> Animal
  • qualified: class Cat < M::Base (scope_resolution) -> Base

It reuses the same synthesize-base-node-if-absent + add_edge pattern as the other language branches.

Verification

  • Added a subclass to the Ruby fixture and a regression test.
  • pytest tests/test_languages.py -> 268 passed, 13 skipped (existing Ruby tests unaffected).
  • ruff check --config pyproject.toml -> clean.

Before / after

class Dog < Animal

  • before: only contains
  • after: inherits Dog->Animal

`class Dog < Animal` exposes the base in the `superclass` field, but the
inheritance handler in `_extract_generic` had branches for
java/kotlin/c#/scala/cpp/php/swift/python and none for Ruby, so every Ruby
`inherits` edge was silently dropped (contains/methods/calls unaffected).

Add a Ruby branch that reads the `superclass` field, handling both a bare
`constant` (`< Animal`) and a `scope_resolution` (`< Foo::Bar` -> Bar).
Adds a subclass to the Ruby fixture and a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Merged into v8 as a19b9e9 (your authorship). Verified: exactly one ApiClient node (no duplicate) and the inherits edge targets the real class node with its source_file intact — the synth-if-absent path correctly resolves to the existing definition. Handles bare and M::Base qualified forms. Full suite 2767 passed. Ships next release.

@safishamsi safishamsi closed this Jul 1, 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.

3 participants