Skip to content

Commit 2115616

Browse files
authored
Merge pull request #351 from gren-lang/push-xwwroxnzvkos
When executing make or run, never consider modules from dependencies as roots.
2 parents 0343e77 + 72b878a commit 2115616

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

builder/src/Build.hs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,20 @@ crawlDeps env mvar sources deps blockedValue =
262262
where
263263
crawlNew name () = fork (crawlModule env mvar sources (DocsNeed False) name)
264264

265+
crawlRootModuleHelp :: Env -> MVar StatusDict -> Sources -> DocsNeed -> ModuleName.Raw -> IO Status
266+
crawlRootModuleHelp env@(Env _ _ _ _ _ locals _) mvar sources docsNeed name =
267+
case Map.lookup name sources of
268+
Just source ->
269+
if Name.isKernel name
270+
then return $ SBadImport Import.NotFound
271+
else case Map.lookup name locals of
272+
Nothing ->
273+
crawlFile env mvar sources docsNeed name source
274+
Just local@(Details.Local _ deps _) ->
275+
crawlDeps env mvar sources deps (SCached local)
276+
Nothing ->
277+
return $ SBadImport Import.NotFound
278+
265279
crawlModule :: Env -> MVar StatusDict -> Sources -> DocsNeed -> ModuleName.Raw -> IO Status
266280
crawlModule env@(Env _ _ projectType _ _ locals foreigns) mvar sources docsNeed name =
267281
case Map.lookup name sources of
@@ -963,12 +977,7 @@ crawlRoot :: Env -> MVar StatusDict -> Sources -> RootLocation -> IO RootStatus
963977
crawlRoot env mvar sources root =
964978
case root of
965979
LInside name ->
966-
do
967-
statusMVar <- newEmptyMVar
968-
statusDict <- takeMVar mvar
969-
putMVar mvar (Map.insert name statusMVar statusDict)
970-
putMVar statusMVar =<< crawlModule env mvar sources (DocsNeed False) name
971-
return (SInside name)
980+
crawlRootModule env mvar sources name
972981
LOutside _ ->
973982
error "Bad assumption"
974983

@@ -978,7 +987,7 @@ crawlRootModule env mvar sources root =
978987
statusMVar <- newEmptyMVar
979988
statusDict <- takeMVar mvar
980989
putMVar mvar (Map.insert root statusMVar statusDict)
981-
putMVar statusMVar =<< crawlModule env mvar sources (DocsNeed False) root
990+
putMVar statusMVar =<< crawlRootModuleHelp env mvar sources (DocsNeed False) root
982991
return (SInside root)
983992

984993
-- CHECK ROOTS

0 commit comments

Comments
 (0)