diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index 8afb5e29a0..57aa4a9d94 100755 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -1771,6 +1771,38 @@ let main0(ctok, argv, referenceResolver, bannerAlreadyPrinted, openBinariesInMem with e -> errorRecoveryNoRange e exiter.Exit 1 + + let inputs = + // Deduplicate module names + let seen = Dictionary>() + let deduplicate (paths: Set) path (qualifiedNameOfFile: QualifiedNameOfFile) = + let count = if paths.Contains path then paths.Count else paths.Count + 1 + seen.[qualifiedNameOfFile.Text] <- Set.add path paths + let id = qualifiedNameOfFile.Id + if count = 1 then qualifiedNameOfFile else QualifiedNameOfFile(Ident(id.idText + "___" + count.ToString(),id.idRange)) + inputs + |> List.map (fun (input,x) -> + match input with + | ParsedInput.ImplFile (ParsedImplFileInput.ParsedImplFileInput(fileName,isScript,qualifiedNameOfFile,scopedPragmas,hashDirectives,modules,(isLastCompiland,isExe))) -> + let path = Path.GetDirectoryName fileName + match seen.TryGetValue qualifiedNameOfFile.Text with + | true, paths -> + let qualifiedNameOfFile = deduplicate paths path qualifiedNameOfFile + let input = ParsedInput.ImplFile(ParsedImplFileInput.ParsedImplFileInput(fileName,isScript,qualifiedNameOfFile,scopedPragmas,hashDirectives,modules,(isLastCompiland,isExe))) + input,x + | _ -> + seen.Add(qualifiedNameOfFile.Text,Set.singleton path) + input,x + | ParsedInput.SigFile (ParsedSigFileInput.ParsedSigFileInput(fileName,qualifiedNameOfFile,scopedPragmas,hashDirectives,modules)) -> + let path = Path.GetDirectoryName fileName + match seen.TryGetValue qualifiedNameOfFile.Text with + | true, paths -> + let qualifiedNameOfFile = deduplicate paths path qualifiedNameOfFile + let input = ParsedInput.SigFile (ParsedSigFileInput.ParsedSigFileInput(fileName,qualifiedNameOfFile,scopedPragmas,hashDirectives,modules)) + input,x + | _ -> + seen.Add(qualifiedNameOfFile.Text,Set.singleton path) + input,x) if tcConfig.parseOnly then exiter.Exit 0 if not tcConfig.continueAfterParseFailure then