@@ -21,7 +21,7 @@ import TCMisc
2121import Unify
2222
2323import FStringCompat (FString , mkFString , getFString )
24- import Id (mkId )
24+ import Id (Id , mkId )
2525import PreIds
2626import CSyntax
2727import Util (separate , concatMapM , quote , headOrErr , toMaybe , boolCompress )
@@ -39,8 +39,8 @@ import CType(typeclassId, isTNum, getTNum)
3939-- a list of the contexts which failed to reduce, this function
4040-- returns the list of error messages which should be reported
4141--
42- handleContextReduction :: Position -> [VPred ] -> TI a
43- handleContextReduction pos vps =
42+ handleContextReduction :: Maybe Id -> Position -> [VPred ] -> TI a
43+ handleContextReduction mid pos vps =
4444 do
4545 -- We used to remove duplicates:
4646 -- let vps' = nubVPred vps
@@ -80,15 +80,15 @@ handleContextReduction pos vps =
8080 then vps_reduced_nicenames
8181 else is_mod_arrow_vps
8282
83- emsgs <- mapM (handleContextReduction' pos) err_vps
83+ emsgs <- mapM (handleContextReduction' mid pos) err_vps
8484
8585 errs " handleContextReduction" emsgs
8686
8787-- --------------------
8888
8989-- This helper function takes one predicate at a time
90- handleContextReduction' :: Position -> (VPred , [VPred ]) -> TI EMsg
91- handleContextReduction' pos
90+ handleContextReduction' :: Maybe Id -> Position -> (VPred , [VPred ]) -> TI EMsg
91+ handleContextReduction' mid pos
9292 p@ ((VPred vpi (PredWithPositions (IsIn c@ (Class { name= (CTypeclass cid) }) ts) _)), _)
9393 | cid == idBitwise =
9494 case ts of
@@ -167,15 +167,15 @@ handleContextReduction' pos
167167 " SizedLiteral instance contains wrong number of types" )
168168 | cid == idWrapField =
169169 case ts of
170- [TCon (TyStr name _), t, _] -> return $ handleCtxRedWrapField pos p name t
170+ [TCon (TyStr name _), t, _] -> return $ handleCtxRedWrapField mid pos p name t
171171 _ -> internalError(" handleContextReduction': " ++
172172 " WrapField instance contains wrong number of types" )
173173
174174-- | cid == idLiteral =
175175-- | cid == idRealLiteral =
176176-- | cid == idStringLiteral =
177177
178- handleContextReduction' pos p =
178+ handleContextReduction' mid pos p =
179179 return (defaultContextReductionErr pos p)
180180
181181-- --------------------
@@ -461,9 +461,9 @@ handleCtxRedPrimPort pos (vp, reduced_ps) userty =
461461
462462-- --------------------
463463
464- handleCtxRedWrapField :: Position -> (VPred , [VPred ]) -> FString -> Type -> EMsg
465- handleCtxRedWrapField pos (vp, reduced_ps) name userty =
466- (pos, EBadIfcType Nothing $
464+ handleCtxRedWrapField :: Maybe Id -> Position -> (VPred , [VPred ]) -> FString -> Type -> EMsg
465+ handleCtxRedWrapField mid pos (vp, reduced_ps) name userty =
466+ (pos, EBadIfcType ( fmap pfpString mid) $
467467 " The interface method `" ++ getFString name ++
468468 " ' uses type(s) that are not in the Bits or SplitPorts typeclasses: " ++
469469 intercalate " , " (concatMap bitsPredType reduced_ps)
@@ -1036,7 +1036,7 @@ earlyContextReduction pos ps =
10361036 rs <- mapM try_pred ps
10371037 let err_preds = map fst (filter (not . snd ) rs)
10381038 when (not (null err_preds)) $
1039- handleContextReduction pos err_preds
1039+ handleContextReduction Nothing pos err_preds
10401040
10411041-- ========================================================================
10421042
0 commit comments