Skip to content

Commit 83ddc25

Browse files
committed
fix ModLocation for nameless modules
1 parent 7cb37ea commit 83ddc25

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,11 @@ getModSummaryFromImports env fp modTime contents = do
731731
liftIO $ evaluate $ rnf srcImports
732732
liftIO $ evaluate $ rnf textualImports
733733

734-
modLoc <- liftIO $ mkHomeModLocation dflags mod fp
734+
modLoc <- liftIO $ if mod == mAIN_NAME
735+
-- specially in tests it's common to have lots of nameless modules
736+
-- mkHomeModLocation will map them to the same hi/hie locations
737+
then mkHomeModLocation dflags (pathToModuleName fp) fp
738+
else mkHomeModLocation dflags mod fp
735739

736740
let modl = mkHomeModule (hscHomeUnit (hscSetFlags dflags env)) mod
737741
sourceType = if "-boot" `isSuffixOf` takeExtension fp then HsBootFile else HsSrcFile
@@ -994,3 +998,11 @@ lookupName hsc_env mod name = do
994998
ATcId{tct_id=id} -> return (AnId id)
995999
_ -> panic "tcRnLookupName'"
9961000
return res
1001+
1002+
1003+
pathToModuleName :: FilePath -> ModuleName
1004+
pathToModuleName = mkModuleName . map rep
1005+
where
1006+
rep c | isPathSeparator c = '_'
1007+
rep ':' = '_'
1008+
rep c = c

0 commit comments

Comments
 (0)