@@ -81,10 +81,11 @@ withOrig f x = fmap (x, ) $ f x
8181parseConstraint ::
8282 HasCallStack
8383 => (Class -> [Type ] -> Maybe a ) -- ^ Do we want to try and match against this?
84+ -> SDoc -- ^ Description of above predicate
8485 -> (a -> Maybe b ) -- ^ Parser for the class arguments
8586 -> Ct -- ^ Constraint to parse
8687 -> ParseResult e (GenLocated CtLoc b )
87- parseConstraint p f ct = fmap (L $ ctLoc ct) $
88+ parseConstraint p doc f ct = fmap (L $ ctLoc ct) $
8889 -- TODO: classify up to equalities..?
8990 case classifyPredType (ctPred ct) of
9091 ClassPred cls args | Just a <- p cls args ->
@@ -97,6 +98,8 @@ parseConstraint p f ct = fmap (L $ ctLoc ct) $
9798 , showSDocUnsafe (ppr cls)
9899 , " constraint with arguments:\n "
99100 , unlines (map (showSDocUnsafe . ppr) args)
101+ , " \n When parsing " ++ showSDocUnsafe (ppr ct)
102+ , " \n looking for " ++ showSDocUnsafe doc
100103 , " \n at\n "
101104 , prettyCallStack callStack
102105 ]
@@ -110,7 +113,7 @@ parseConstraint' ::
110113 -> ([Type ] -> Maybe a ) -- ^ Parser for the class arguments
111114 -> Ct -- ^ Constraint to parse
112115 -> ParseResult e (GenLocated CtLoc a )
113- parseConstraint' cls = parseConstraint p
116+ parseConstraint' cls = parseConstraint p (ppr cls)
114117 where
115118 p :: Class -> [Type ] -> Maybe [Type ]
116119 p cls' args = if cls == cls' then Just args else Nothing
@@ -152,4 +155,11 @@ parseInjTyConApp tcs tyCon t = do
152155 -- When this is the case, however, by injectivity of 'tyCon' we know that
153156 -- @args1 ~ args1'@, so we can just return /any/ of the matches; we will
154157 -- return the first.
155- lookup tyCon (toList splits)
158+ --
159+ -- 2025-08-26: we ignore constraints here.
160+ -- Prior using ghc-tcplugin-api-0.17 we ignored them by necessity and plugin worked.
161+ -- There is a concern that the plugin should record (equality) constraints
162+ -- used for reasoning in evidences it constructs,
163+ -- but AFAIK, GHC simply has no direct mechanism to do that
164+ -- (see the hoops GHC itself jumps though to make `unsafeCoerce` behave well).
165+ lookup tyCon [ (x,y) | (x,y,_) <- toList splits]
0 commit comments