Skip to content

Commit 3f9a0ef

Browse files
committed
Do the filtering in duplicateImportMsg
1 parent 2d3b1f8 commit 3f9a0ef

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

cabal-install-solver/src/Distribution/Solver/Types/ProjectConfigPath.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,19 @@ cyclicalImportMsg path@(ProjectConfigPath (duplicate :| _)) =
7373
, nest 2 (docProjectConfigPath path)
7474
]
7575

76-
-- | A message for a duplicate import.
76+
-- | A message for a duplicate import. If a check for cyclical imports has
77+
-- already been made then this would report a duplicate import by two different
78+
-- paths.
7779
duplicateImportMsg :: FilePath -> ProjectConfigPath -> [(FilePath, ProjectConfigPath)] -> Doc
78-
duplicateImportMsg duplicate path dupImportsBy =
80+
duplicateImportMsg duplicate path seenImportsBy =
7981
vcat
8082
[ text "duplicate import of" <+> text duplicate <> semi
8183
, nest 2 (docProjectConfigPath path)
82-
, nest 2 (vcat [docProjectConfigPath dib | (_, dib) <- dupImportsBy])
84+
, nest 2 $
85+
vcat
86+
[ docProjectConfigPath dib
87+
| (_, dib) <- filter ((duplicate ==) . fst) seenImportsBy
88+
]
8389
]
8490

8591
docProjectConfigPathFailReason :: VR -> ProjectConfigPath -> Doc

cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ parseProjectSkeleton cacheDir httpTransport verbosity importsBy projectDir sourc
284284
| isCyclicConfigPath normLocPath ->
285285
pure . parseFail $ ParseUtils.FromString (render $ cyclicalImportMsg normLocPath) Nothing
286286
| uniqueImport `elem` seenImports -> do
287-
let dupImportsBy = filter ((uniqueImport ==) . fst) seenImportsBy
288-
pure . parseFail $ ParseUtils.FromString (render $ duplicateImportMsg uniqueImport normLocPath dupImportsBy) Nothing
287+
pure . parseFail $ ParseUtils.FromString (render $ duplicateImportMsg uniqueImport normLocPath seenImportsBy) Nothing
289288
| otherwise -> do
290289
normSource <- canonicalizeConfigPath projectDir source
291290
let fs = (\z -> CondNode z [normLocPath] mempty) <$> fieldsToConfig normSource (reverse acc)

0 commit comments

Comments
 (0)