From: Javier Sagredo Date: Thu, 7 May 2026 00:01:33 +0000 (+0200) Subject: Skip data fam-instances in reduceTypeArg to avoid infinite recursion X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=5a09863f9c50bb6234a8e5b3bf8c9805b21579de;p=classgraph.git Skip data fam-instances in reduceTypeArg to avoid infinite recursion The data-family R: rewrite makes a data fam-instance's fiRhs structurally equal to its FamilyApp LHS (e.g. for `data instance Crate Int`, fiRhs is `FamilyApp Crate [Int]`). reduceTypeArg used to unify the use site against fiArgs and recurse on applySubst(fiRhs, subst) — which produced the same FamilyApp shape again and looped forever for any constraint mentioning a data fam-instance. Skip data fam-instances in reduceTypeArg entirely. Their RHS is opaque (the synthetic R: TyCon pre-rewrite, the circular FamilyApp post-rewrite); reducing through them never makes progress, only ever loops. The use-site FamilyApp falls through unchanged, which addFamilyLinksFromArgs / the predicate-node + chain machinery then handle as the data-family use site they actually are. Co-Authored-By: Claude Opus 4.7 (1M context) --- diff --git a/data/viewer.js b/data/viewer.js index cb84f9f..f56ff8a 100644 --- a/data/viewer.js +++ b/data/viewer.js @@ -1117,6 +1117,13 @@ const reducedArgs = args.map(reduceTypeArg); for (const fi of graph.meta.pdFamInstances) { if (qid(fi.fiFamily) !== qid(q)) continue; + // Skip data fam-instances: their fiRhs is opaque (the + // synthetic R: TyCon, or after the data-family rewrite the + // *abstract* FamilyApp form that's structurally equal to the + // LHS). Recursing on either form either loops forever or + // produces no progress, so leave the FamilyApp untouched and + // let the outer flow handle it as a use site. + if (fi.fiIsData) continue; if (fi.fiArgs.length !== reducedArgs.length) continue; const subst = {}; let ok = true;