diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 49c11ad003..b32174f885 100755 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -4947,7 +4947,8 @@ module private ScriptPreprocessClosure = [ClosedSourceFile(filename,m,None,[],[],[])] // Don't traverse into .fs leafs. let loadedSources = (!tcConfig).GetAvailableLoadedSources() |> List.rev |> List.map AddFileIfNotSeen |> List.concat - ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns) :: loadedSources |> List.map FindClosure |> List.concat // Final closure is in reverse order. Keep the closed source at the top. + (loadedSources |> List.map FindClosure |> List.concat) + @ [ClosedSourceFile(filename,m,Some(input),!errors,!warnings,!noWarns)] | None -> [ClosedSourceFile(filename,m,None,!errors,!warnings,[])] closureDirectives |> List.map FindClosure |> List.concat, !tcConfig @@ -5009,7 +5010,7 @@ module private ScriptPreprocessClosure = let rootWarnings = rootWarnings |> List.filter isRootRange let result : LoadClosure = - { SourceFiles = List.groupByFirst !sourceFiles + { SourceFiles = List.groupByFirst !sourceFiles |> List.rev References = List.groupByFirst references UnresolvedReferences = unresolvedReferences Inputs = !sourceInputs