]> Repositorios git - classgraph.git/commit
Reduce pivot's sub-args before unifying in replaceFamilyApp
authorJavier Sagredo <[email protected]>
Thu, 7 May 2026 01:03:58 +0000 (03:03 +0200)
committerJavier Sagredo <[email protected]>
Thu, 7 May 2026 01:03:58 +0000 (03:03 +0200)
commitb459422c5227b98bdb35a317ed256b2bc5fd7e44
tree9e5f6cf12a6df8ea58df4ba9ba81eaf0592470b2
parent086b6364fbf8473ab293350941a84bcbdb32c0a7
Reduce pivot's sub-args before unifying in replaceFamilyApp

When a constraint nests type families — `F (G a)` where `G` has a
known type-instance equation — the outer family's pivot search
finds `FamilyApp F [FamilyApp G [...]]`, but biUnify against
`fi.fiArgs = [TyConApp Bar [...]]` fails because tags differ. The
fam-instance is rejected and a placeholder fires, even though the
inner reduction would produce a unifiable shape.

Reduce the pivot's sub-args via reduceTypeArg before biUnify.
For the user's case `ChainDepState (BlockProtocol (ShelleyBlock proto era))`:
* Without this fix: pivot args = `[FamilyApp BlockProtocol [...]]`,
  biUnify against `TyConApp Praos [TyVarRef 0]` fails.
* With this fix: reduced pivot args = `[TyVarRef proto]`, biUnify
  succeeds (TyVarRef wildcards both sides per biUnify semantics),
  and the chain edges from the data fam-instances `ChainDepState
  (Praos c)` / `ChainDepState (TPraos c)` to the predicate node
  finally surface.

Trade-off: when the inner reduction unwraps a family to a TyVarRef
(as above), every concrete data-instance of the outer family now
matches via biUnify's wildcard rule. So instead of a single chain
the user sees one per concrete instance — Praos AND TPraos in this
example. That's consistent with the existing "Are the resolution
chains deterministic?" caveat in INTERNALS.md: ambiguous matches
surface as multiple chain edges and let the reader pick.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
data/viewer.js