@@ -739,9 +739,13 @@ match_co renv subst (TyConAppCo r1 tc1 cos1) co2
| r1 == r2 && tc1 == tc2
-> match_cos renv subst cos1 cos2
_ -> Nothing
match_co _ _ co1 co2
= pprTrace "match_co: needs more cases" (ppr co1 $$ ppr co2) Nothing
match_co _ _ _co1 _co2
-- Currently just deals with CoVarCo, TyConAppCo and Refl
#ifdef DEBUG
= pprTrace "match_co: needs more cases" (ppr _co1 $$ ppr _co2) Nothing
#else
= Nothing
#endif

match_cos :: RuleMatchEnv
-> RuleSubst
@@ -1225,6 +1225,9 @@ editFile str =
when (null cmd)
$ throwGhcException (CmdLineError "editor not set, use :set editor")
lineOpt <- liftIO $ do
let sameFile p1 p2 = liftA2 (==) (canonicalizePath p1) (canonicalizePath p2)
`catchIO` (\_ -> return False)

curFileErrs <- filterM (\(f, _) -> unpackFS f `sameFile` file) errs
return $ case curFileErrs of
(_, line):_ -> " +" ++ show line
@@ -3191,12 +3194,6 @@ expandPathIO p =
other ->
return other

sameFile :: FilePath -> FilePath -> IO Bool
sameFile path1 path2 = do
absPath1 <- canonicalizePath path1
absPath2 <- canonicalizePath path2
return $ absPath1 == absPath2

wantInterpretedModule :: GHC.GhcMonad m => String -> m Module
wantInterpretedModule str = wantInterpretedModuleName (GHC.mkModuleName str)

@@ -158,13 +158,11 @@ xchg(StgPtr p, StgWord w)
: "memory"
);
#elif aarch64_HOST_ARCH
// Don't think we actually use tmp here, but leaving
// it for consistent numbering
StgWord tmp;
__asm__ __volatile__ (
"1: ldaxr %0, [%3]\n"
" stlxr %w0, %2, [%3]\n"
" cbnz %w0, 1b\n"
" stlxr %w1, %2, [%3]\n"
" cbnz %w1, 1b\n"
" dmb sy\n"
: "=&r" (result), "=&r" (tmp)
: "r" (w), "r" (p)
@@ -83,10 +83,12 @@ evtConcat :: [Event] -> Event
evtConcat = foldl' evtCombine evtNothing
{-# INLINE evtConcat #-}

-- | The lifetime of a registration.
-- | The lifetime of an event registration.
--
-- @since 4.8.1.0
data Lifetime = OneShot | MultiShot
data Lifetime = OneShot -- ^ the registration will be active for only one
-- event
| MultiShot -- ^ the registration will trigger multiple times
deriving (Show, Eq)

-- | The longer of two lifetimes.
@@ -95,6 +97,7 @@ elSupremum OneShot OneShot = OneShot
elSupremum _ _ = MultiShot
{-# INLINE elSupremum #-}

-- | @mappend@ == @elSupremum@
instance Monoid Lifetime where
mempty = OneShot
mappend = elSupremum
@@ -456,38 +456,54 @@ onFdEvent mgr fd evs

| otherwise = do
fdds <- withMVar (callbackTableVar mgr fd) $ \tbl ->
IT.delete (fromIntegral fd) tbl >>= maybe (return []) selectCallbacks
IT.delete (fromIntegral fd) tbl >>= maybe (return []) (selectCallbacks tbl)
forM_ fdds $ \(FdData reg _ cb) -> cb reg evs
where
-- | Here we look through the list of registrations for the fd of interest
-- and sort out which match the events that were triggered. We re-arm
-- the fd as appropriate and return this subset.
selectCallbacks :: [FdData] -> IO [FdData]
selectCallbacks fdds = do
let matches :: FdData -> Bool
-- and sort out which match the events that were triggered. We,
--
-- 1. re-arm the fd as appropriate
-- 2. reinsert registrations that weren't triggered and multishot
-- registrations
-- 3. return a list containing the callbacks that should be invoked.
selectCallbacks :: IntTable [FdData] -> [FdData] -> IO [FdData]
selectCallbacks tbl fdds = do
let -- figure out which registrations have been triggered
matches :: FdData -> Bool
matches fd' = evs `I.eventIs` I.elEvent (fdEvents fd')
(triggered, saved) = partition matches fdds
(triggered, notTriggered) = partition matches fdds

-- sort out which registrations we need to retain
isMultishot :: FdData -> Bool
isMultishot fd' = I.elLifetime (fdEvents fd') == MultiShot
saved = notTriggered ++ filter isMultishot triggered

savedEls = eventsOf saved
allEls = eventsOf fdds

-- Reinsert multishot registrations.
-- We deleted the table entry for this fd above so we there isn't a preexisting entry
_ <- IT.insertWith (\_ _ -> saved) (fromIntegral fd) saved tbl

case I.elLifetime allEls of
-- we previously armed the fd for multiple shots, no need to rearm
MultiShot | allEls == savedEls ->
return ()

-- either we previously registered for one shot or the
-- events of interest have changed, we must re-arm
_ -> do
_ ->
case I.elLifetime savedEls of
OneShot | haveOneShot ->
-- if there are no saved events there is no need to re-arm
unless (OneShot == I.elLifetime (eventsOf triggered)
&& mempty == savedEls) $
-- if there are no saved events and we registered with one-shot
-- semantics then there is no need to re-arm
unless (OneShot == I.elLifetime allEls
&& mempty == I.elEvent savedEls) $ do
void $ I.modifyFdOnce (emBackend mgr) fd (I.elEvent savedEls)
_ ->
-- we need to re-arm with multi-shot semantics
void $ I.modifyFd (emBackend mgr) fd
(I.elEvent allEls) (I.elEvent savedEls)
return ()

return triggered

@@ -6,3 +6,7 @@
:e ./Bad.hs
:l Good.hs
:e
+
:e foo
:l Bad.hs
:e bar
@@ -1,9 +1,17 @@

Bad.hs:3:8:
Bad.hs:3:8: error:
lexical error in string/character literal at character '\n'

Bad.hs:3:8:
Bad.hs:3:8: error:
lexical error in string/character literal at character '\n'

Bad.hs:3:8:
Bad.hs:3:8: error:
lexical error in string/character literal at character '\n'

<interactive>:10:1: error: parse error on input ‘+’

Bad.hs:3:8: error:
lexical error in string/character literal at character '\n'

Bad.hs:3:8: error:
lexical error in string/character literal at character '\n'
@@ -2,3 +2,5 @@ Good.hs
Bad.hs +3
./Bad.hs +3
Good.hs
foo
bar