Skip to content

fix(dart): resolve every superclass constraint in a mixin on clause - #4899

Closed
ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-dart-mixin-on-clause-multiple-constraints
Closed

ayushcodes10 wants to merge 2 commits into
Graphify-Labs:v8from
ayushcodes10:fix-dart-mixin-on-clause-multiple-constraints

Conversation

@ayushcodes10

Copy link
Copy Markdown
Contributor

Bug

A Dart mixin's on clause may list several comma-separated superclass constraints (mixin Selectable on Comparable<T>, State<X> {}), unlike extends, which only ever has one target since Dart classes have single inheritance. The class-header parser in extract_dart only ever captured the single type name immediately after extends/on via a regex with no comma handling. For extends that's correct; for on it silently dropped every constraint after the first — no node, no edge, and the leftover , State<X> text was neither consumed nor matched by the later with/implements checks, so it just vanished.

No existing issue or PR covers this; found via self-audit of graphify/extractors/dart.py (csharp.py had nothing demonstrable after a thorough read). The only open PR touching the same class-header block (#2249, "reduce Dart extraction noise") refactors the mixin/interface cleanup helper but does not touch the extends/on comma-list parsing itself — no overlap. Three other open PRs (#3651, #2114, and closed #415) are full tree-sitter rewrites that would eventually replace this regex extractor entirely, but none are merged, so this interim fix is still worth landing.

Fix

Refactored the extends/on parsing into a _consume_generic_args helper plus a loop that, only when the keyword is on, keeps consuming further comma-separated , TypeName<Generics> entries into a base_entries list. extends still only ever reads one entry, so its behavior is unchanged. The later "map inheritance relation" block now iterates every entry in base_entries instead of a single base_class/generics pair, so each constraint gets its own inherits edge and its generic argument still surfaces as a references edge.

Tests

Added to tests/test_dart.py:

  • test_mixin_on_clause_with_multiple_superclass_constraints — regression: asserts both constraints get inherits edges, and the second one's generic argument still surfaces as a references edge.
  • test_mixin_on_clause_with_single_superclass_constraint_is_unaffected — control: a single-constraint on clause still resolves exactly as before.

Verification

  • Confirmed the bug pre-fix via git show upstream/v8:... swapped into place (restored byte-identical afterward): the regression test fails (only the first constraint got an edge), the control passes both before and after.
  • Full suite: 3 failed, 9115 passed, 82 skipped, 1 xfailed — the 3 failures are the pre-existing flakes in test_erlang_extractor.py, test_r_extractor.py, and the skill backtick test, unrelated to this change.
  • python3 -m tools.skillgen --check: check OK: 134 artifact(s) match committed output and expected/.

A mixin's on clause may list several comma separated superclass
constraints, unlike extends, which Dart only ever gives one target
since classes have single inheritance. The header parser read only
the single type name right after extends or on and stopped there, so
every constraint after the first in an on clause was silently
dropped: no node, no inherits edge, and its generic argument never
surfaced as a reference either.

Factored the generic argument reader into its own helper and added a
loop that, only for on, keeps consuming further comma separated
entries. Extends still only ever reads one entry, so its behavior is
unchanged. The later relation mapping block now walks every entry
collected this way instead of a single base class and generics pair.
Covers a mixin on clause naming two superclass constraints, asserting
both get an inherits edge and the second one's generic argument
still surfaces as a reference, plus a control confirming a single
constraint on clause still resolves exactly as before.
@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 31, 2026
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @ayushcodes10. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).

Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.


Graphify review — findings

Fixes Dart mixin extraction so mixin Foo on A, B {} emits an inherits edge for every comma-separated superclass constraint, not just the first. Each constraint's generic arguments are parsed too, so something like State<WidgetState> still surfaces a references edge to WidgetState. extends keeps its single-base behavior, and a single-constraint on resolves as before. Tests cover both the multi-constraint case and a single-constraint control.

No blocking issues surfaced.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 45 functions depend on the 44 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract_dart() — 15 callers, 9 callees

Verification — 45 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 45 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

2 of 479 test file(s) selected (0%) via static blast radius.

  • tests/test_dart.py — impact, changed-test
  • tests/test_extract.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

Formal verification

No difference found (not proven): No behavior difference found in extract\_dart (not a proof).

The verifier ran both versions of extract\_dart on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.

Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.

Note: An input the sampler did not try could still differ.

· 1 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Nov 1, 2026
…for video + extractors

The four @ayushcodes10 extractor fixes (#4902 R, #4900 elixir, #4899 dart,
#4897 fortran) change per-file AST output and are AST-cached; they share
the global 31->32 bump already landed via #4908/#4895. Extend the comment
to credit them, and add the 0.9.100 changelog entries for #4842 and the four.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Landed in v0.9.100, now on PyPI (pip install graphifyy==0.9.100). A Dart mixin on A, B clause resolves every superclass constraint. Thanks for the fix, @ayushcodes10.

@safishamsi safishamsi closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants