Skip to content

fix(extract): emit inherits edge for JavaScript class extends - #1790

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/js-class-extends-inherits
Closed

Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/js-class-extends-inherits

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Bug

Plain JavaScript class heritage was dropped: class Dog extends Animal {} emitted no inherits edge, while the equivalent TypeScript did.

Root cause

The JavaScript grammar stores extends and its identifier directly under class_heritage. TypeScript wraps the base in an extends_clause. The walker only handled the wrapped shape.

Fix

When a class_heritage node has no extends_clause or implements_clause, treat the heritage node itself as the JavaScript extends clause. The guard preserves the existing TypeScript path and prevents duplicate edges.

The implementation remains precision-first: direct same-file and imported identifiers resolve; runtime expressions such as extends mixin(Animal) are not converted into fabricated static inheritance. Qualified member expressions require namespace-aware resolution and remain outside this focused fix.

Validation

  • Added same-file JavaScript inheritance coverage.
  • Added imported JavaScript inheritance coverage.
  • Added a dynamic-base negative control.
  • Existing TypeScript interface, generic, imported and implements cases remain covered.
  • tests/test_ts_inheritance.py: 10 passed.
  • Ruff and git diff --check: passed.

@Synvoya
Synvoya force-pushed the fix/js-class-extends-inherits branch 3 times, most recently from 7e98bde to e8c3461 Compare July 27, 2026 02:41
@Synvoya

Synvoya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up audit against current v8 found that JavaScript member-expression parents such as class Dog extends ns.Animal were still dropped. The branch now handles that AST shape and adds a regression test. Current validation: tests/test_ts_inheritance.py 9 passed; Ruff and git diff --check passed.

@Synvoya
Synvoya force-pushed the fix/js-class-extends-inherits branch from e8c3461 to da59be9 Compare July 27, 2026 04:15
@Synvoya

Synvoya commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Precision follow-up: I removed the member-expression tail normalization mentioned in my previous comment. Treating ns.Animal as bare Animal can falsely bind an unrelated same-file class without namespace-aware resolution. The final branch stays focused on direct JavaScript heritage identifiers, adds imported-class coverage and a runtime-expression negative control, and is squashed to one commit.

safishamsi pushed a commit that referenced this pull request Aug 30, 2026
A plain JavaScript `class Dog extends Animal` produced no inherits edge — only the
TypeScript extends_clause/implements_clause shapes were handled, not the bare identifier
directly under class_heritage that JS emits. Fall back to reading heritage identifiers when
no clause is present, so JS class inheritance is captured; a dynamic base (mixin call) yields
nothing and TS is not double-emitted.
safishamsi added a commit that referenced this pull request Aug 30, 2026
Ships two batches: the robot/defang/watch/semantic-guard set — Robot Framework extractor
(#3192), generalized control-token defang (#3183), watch unresolved-link preservation
(#3190), unverified-semantic-loss guard (#3203), hook-guard search detection (#3121),
stale-SKILL.md backup (#3144), report/wiki count fixes (#3148/#3127); and a rescued batch of
@Synvoya cross-language inheritance-edge corrections (JS #1790, PHP #1791, Scala #1792/#1794,
Kotlin #1793, C# #1817, Go #1818) that had been buried in the backlog for ~7 weeks.

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

Copy link
Copy Markdown
Member

Shipped in v0.9.53 via authorship-preserving cherry-pick so you keep contributor-graph credit. Thanks @Synvoya — this was verified still-live on the current tree and landed as part of a cross-language heritage-edge batch. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.53

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