@@ -133,7 +133,9 @@ import "ghc" GHC.Types.Unique.Map
133
133
import GHC.Types.Unique.Map
134
134
#endif
135
135
136
+ #if __GLASGOW_HASKELL__ < 908
136
137
import GHC.Types.Unique.Map.Extra
138
+ #endif
137
139
138
140
-- clash-prelude
139
141
import Clash.Prelude (Vec ((:>) , Nil ))
@@ -486,7 +488,7 @@ tupT tys = noLoc $ HsTupleTy noExt hsBoxedTuple tys
486
488
487
489
vecT :: SrcSpanAnnA -> [LHsType GhcPs ] -> LHsType GhcPs
488
490
vecT s [] = L s $ HsParTy noExt (conT s (thName ''Vec) `appTy` tyNum s 0 `appTy` (varT s (genLocName s " vec" )))
489
- vecT s tys = L s $ HsParTy noExt (conT s (thName ''Vec) `appTy` tyNum s (length tys) `appTy` head tys )
491
+ vecT s tys@ (ty : _) = L s $ HsParTy noExt (conT s (thName ''Vec) `appTy` tyNum s (length tys) `appTy` ty )
490
492
491
493
tyNum :: SrcSpanAnnA -> Int -> LHsType GhcPs
492
494
tyNum s i = L s (HsTyLit noExtField (HsNumTy GHC. NoSourceText (fromIntegral i)))
@@ -618,8 +620,10 @@ lamE pats expr = noLoc $ HsLam noExtField mg
618
620
mg :: MatchGroup GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs ))
619
621
#if __GLASGOW_HASKELL__ < 906
620
622
mg = MG noExtField matches GHC. Generated
621
- #else
623
+ #elif __GLASGOW_HASKELL__ < 908
622
624
mg = MG GHC. Generated matches
625
+ #else
626
+ mg = MG (GHC. Generated GHC. DoPmc ) matches
623
627
#endif
624
628
625
629
matches :: GenLocated SrcSpanAnnL [GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs )))]
@@ -874,18 +878,19 @@ checkCircuit = do
874
878
topNames = portNames Slave slaves <> portNames Master masters
875
879
nameMap = listToUniqMap_C mappend $ topNames <> concatMap bindingNames binds
876
880
877
- duplicateMasters <- concat <$> forM (nonDetUniqMapToList nameMap) \ (name, occ) ->
881
+ duplicateMasters <- concat <$> forM (nonDetUniqMapToList nameMap) \ (name, occ) -> do
882
+ let isIgnored = case unpackFS name of {(' _' : _) -> True ; _ -> False }
883
+
878
884
case occ of
885
+ ([] , [] ) -> pure []
879
886
([_], [_]) -> pure []
880
- (ss, ms) -> do
881
- unless (head (unpackFS name) == ' _' ) $ do
882
- when (null ms) $ errM (locA (head ss)) $ " Slave port " <> show name <> " has no associated master"
883
- when (null ss) $ errM (locA (head ms)) $ " Master port " <> show name <> " has no associated slave"
887
+ (s: _, [] ) | not isIgnored -> errM (locA s) (" Slave port " <> show name <> " has no associated master" ) >> pure []
888
+ ([] , m: _) | not isIgnored -> errM (locA m) (" Master port " <> show name <> " has no associated slave" ) >> pure []
889
+ (ss@ (s: _: _), _) ->
884
890
-- would be nice to show locations of all occurrences here, not sure how to do that while
885
891
-- keeping ghc api
886
- when (length ss > 1 ) $
887
- errM (locA (head ss)) $ " Slave port " <> show name <> " defined " <> show (length ss) <> " times"
888
-
892
+ errM (locA s) (" Slave port " <> show name <> " defined " <> show (length ss) <> " times" ) >> pure []
893
+ (_ss, ms) -> do
889
894
-- if master is defined multiple times, we broadcast it
890
895
if length ms > 1
891
896
then pure [name]
0 commit comments