Skip to content

Commit c4cbd97

Browse files
committed
update tests
1 parent 465676e commit c4cbd97

File tree

8 files changed

+240
-205
lines changed

8 files changed

+240
-205
lines changed

src/Compiler/Service/FSharpCheckerResults.fs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,16 @@ module internal ParseAndCheckFile =
22192219

22202220
let collectOne severity diagnostic =
22212221
for diagnostic in
2222-
DiagnosticHelpers.ReportDiagnostic(options, false, mainInputFileName, fileInfo, diagnostic, severity, suggestNamesForErrors, flatErrors) do
2222+
DiagnosticHelpers.ReportDiagnostic(
2223+
options,
2224+
false,
2225+
mainInputFileName,
2226+
fileInfo,
2227+
diagnostic,
2228+
severity,
2229+
suggestNamesForErrors,
2230+
flatErrors
2231+
) do
22232232
diagnosticsCollector.Add diagnostic
22242233

22252234
if severity = FSharpDiagnosticSeverity.Error then
@@ -2598,7 +2607,14 @@ module internal ParseAndCheckFile =
25982607

25992608
// Initialize the error handler
26002609
let errHandler =
2601-
DiagnosticsHandler(true, mainInputFileName, tcConfig.diagnosticsOptions, sourceText, suggestNamesForErrors, tcConfig.flatErrors)
2610+
DiagnosticsHandler(
2611+
true,
2612+
mainInputFileName,
2613+
tcConfig.diagnosticsOptions,
2614+
sourceText,
2615+
suggestNamesForErrors,
2616+
tcConfig.flatErrors
2617+
)
26022618

26032619
use _ = UseDiagnosticsLogger errHandler.DiagnosticsLogger
26042620

src/Compiler/Service/service.fs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ module CompileHelpers =
137137
/// Compile using the given flags. Source files names are resolved via the FileSystem API. The output file must be given by a -o flag.
138138
let compileFromArgs (ctok, argv: string[], legacyReferenceResolver, tcImportsCapture, dynamicAssemblyCreator) =
139139

140-
let diagnostics, diagnosticsLogger, loggerProvider = mkCompilationDiagnosticsHandlers (argv |> Array.contains "--flaterrors")
140+
let diagnostics, diagnosticsLogger, loggerProvider =
141+
mkCompilationDiagnosticsHandlers (argv |> Array.contains "--flaterrors")
141142

142143
let result =
143144
tryCompile diagnosticsLogger (fun exiter ->
@@ -507,7 +508,15 @@ type BackgroundCompiler
507508
Interlocked.Increment(&actualParseFileCount) |> ignore
508509

509510
let parseDiagnostics, parseTree, anyErrors =
510-
ParseAndCheckFile.parseFile (sourceText, fileName, options, userOpName, suggestNamesForErrors, flatErrors, captureIdentifiersWhenParsing)
511+
ParseAndCheckFile.parseFile (
512+
sourceText,
513+
fileName,
514+
options,
515+
userOpName,
516+
suggestNamesForErrors,
517+
flatErrors,
518+
captureIdentifiersWhenParsing
519+
)
511520

512521
let res = FSharpParseFileResults(parseDiagnostics, parseTree, anyErrors, options.SourceFiles)
513522
parseCacheLock.AcquireLock(fun ltok -> parseFileCache.Set(ltok, (fileName, hash, options), res))
@@ -537,7 +546,14 @@ type BackgroundCompiler
537546
let parseTree, _, _, parseDiagnostics = builder.GetParseResultsForFile fileName
538547

539548
let parseDiagnostics =
540-
DiagnosticHelpers.CreateDiagnostics(builder.TcConfig.diagnosticsOptions, false, fileName, parseDiagnostics, suggestNamesForErrors, builder.TcConfig.flatErrors)
549+
DiagnosticHelpers.CreateDiagnostics(
550+
builder.TcConfig.diagnosticsOptions,
551+
false,
552+
fileName,
553+
parseDiagnostics,
554+
suggestNamesForErrors,
555+
builder.TcConfig.flatErrors
556+
)
541557

542558
let diagnostics = [| yield! creationDiags; yield! parseDiagnostics |]
543559

@@ -836,12 +852,26 @@ type BackgroundCompiler
836852
let diagnosticsOptions = builder.TcConfig.diagnosticsOptions
837853

838854
let parseDiagnostics =
839-
DiagnosticHelpers.CreateDiagnostics(diagnosticsOptions, false, fileName, parseDiagnostics, suggestNamesForErrors, builder.TcConfig.flatErrors)
855+
DiagnosticHelpers.CreateDiagnostics(
856+
diagnosticsOptions,
857+
false,
858+
fileName,
859+
parseDiagnostics,
860+
suggestNamesForErrors,
861+
builder.TcConfig.flatErrors
862+
)
840863

841864
let parseDiagnostics = [| yield! creationDiags; yield! parseDiagnostics |]
842865

843866
let tcDiagnostics =
844-
DiagnosticHelpers.CreateDiagnostics(diagnosticsOptions, false, fileName, tcDiagnostics, suggestNamesForErrors, builder.TcConfig.flatErrors)
867+
DiagnosticHelpers.CreateDiagnostics(
868+
diagnosticsOptions,
869+
false,
870+
fileName,
871+
tcDiagnostics,
872+
suggestNamesForErrors,
873+
builder.TcConfig.flatErrors
874+
)
845875

846876
let tcDiagnostics = [| yield! creationDiags; yield! tcDiagnostics |]
847877

@@ -995,7 +1025,14 @@ type BackgroundCompiler
9951025
let tcDependencyFiles = tcInfo.tcDependencyFiles
9961026

9971027
let tcDiagnostics =
998-
DiagnosticHelpers.CreateDiagnostics(diagnosticsOptions, true, fileName, tcDiagnostics, suggestNamesForErrors, builder.TcConfig.flatErrors)
1028+
DiagnosticHelpers.CreateDiagnostics(
1029+
diagnosticsOptions,
1030+
true,
1031+
fileName,
1032+
tcDiagnostics,
1033+
suggestNamesForErrors,
1034+
builder.TcConfig.flatErrors
1035+
)
9991036

10001037
let diagnostics = [| yield! creationDiags; yield! tcDiagnostics |]
10011038

@@ -1101,7 +1138,7 @@ type BackgroundCompiler
11011138

11021139
let otherFlags = defaultArg otherFlags extraFlags
11031140

1104-
use diagnostics = new DiagnosticsScope (otherFlags |> Array.contains "--flaterrors")
1141+
use diagnostics = new DiagnosticsScope(otherFlags |> Array.contains "--flaterrors")
11051142

11061143
let useSimpleResolution = otherFlags |> Array.exists (fun x -> x = "--simpleresolution")
11071144

@@ -1160,7 +1197,8 @@ type BackgroundCompiler
11601197

11611198
let diags =
11621199
loadClosure.LoadClosureRootFileDiagnostics
1163-
|> List.map (fun (exn, isError) -> FSharpDiagnostic.CreateFromException(exn, isError, range.Zero, false, options.OtherOptions |> Array.contains "--flaterrors"))
1200+
|> List.map (fun (exn, isError) ->
1201+
FSharpDiagnostic.CreateFromException(exn, isError, range.Zero, false, options.OtherOptions |> Array.contains "--flaterrors"))
11641202

11651203
return options, (diags @ diagnostics.Diagnostics)
11661204
}
@@ -1651,7 +1689,7 @@ type FSharpChecker
16511689
member _.GetParsingOptionsFromCommandLineArgs(sourceFiles, argv, ?isInteractive, ?isEditing) =
16521690
let isEditing = defaultArg isEditing false
16531691
let isInteractive = defaultArg isInteractive false
1654-
use errorScope = new DiagnosticsScope (argv |> List.contains "--flaterrors")
1692+
use errorScope = new DiagnosticsScope(argv |> List.contains "--flaterrors")
16551693

16561694
let tcConfigB =
16571695
TcConfigBuilder.CreateNew(

src/Compiler/Symbols/FSharpDiagnostic.fsi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ type public FSharpDiagnostic =
7676
FSharpDiagnostic
7777

7878
static member internal CreateFromException:
79-
diagnostic: PhasedDiagnostic * severity: FSharpDiagnosticSeverity * range * suggestNames: bool * flatErrors: bool ->
79+
diagnostic: PhasedDiagnostic *
80+
severity: FSharpDiagnosticSeverity *
81+
range *
82+
suggestNames: bool *
83+
flatErrors: bool ->
8084
FSharpDiagnostic
8185

8286
/// Newlines are recognized and replaced with (ASCII 29, the 'group separator'),

tests/FSharp.Compiler.ComponentTests/Conformance/InferenceProcedures/RecursiveSafetyAnalysis/RecursiveSafetyAnalysis.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module RecursiveSafetyAnalysis =
2525
|> shouldFail
2626
|> withDiagnostics [
2727
(Error 953, Line 6, Col 6, Line 6, Col 15, "This type definition involves an immediate cyclic reference through an abbreviation")
28-
(Error 1, Line 8, Col 25, Line 8, Col 34, "This expression was expected to have type\n 'bogusType' \nbut here has type\n 'Map<'a,'b>' ")
28+
(Error 1, Line 8, Col 25, Line 8, Col 34, "This expression was expected to have type 'bogusType' but here has type 'Map<'a,'b>'")
2929
]
3030

3131
// SOURCE=E_DuplicateRecursiveRecords.fs SCFLAGS="--test:ErrorRanges" # E_DuplicateRecursiveRecords.fs

tests/service/EditorTests.fs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,13 @@ let s3 = $"abc %d{s.Length}
576576
typeCheckResults.Diagnostics |> shouldEqual [||]
577577
typeCheckResults.GetFormatSpecifierLocationsAndArity()
578578
|> Array.map (fun (range,numArgs) -> range.StartLine, range.StartColumn, range.EndLine, range.EndColumn, numArgs)
579-
|> shouldEqual
580-
[|(3, 10, 3, 12, 1); (4, 10, 4, 15, 1); (5, 10, 5, 16, 1); (7, 11, 7, 15, 1);
581-
(8, 11, 8, 14, 1); (10, 12, 10, 15, 1); (13, 12, 13, 15, 1);
582-
(14, 38, 14, 40, 1); (16, 12, 16, 18, 1); (17, 11, 17, 13, 1);
583-
(17, 18, 17, 22, 1); (18, 10, 18, 12, 0); (19, 15, 19, 17, 1);
584-
(19, 32, 19, 34, 1); (20, 15, 20, 17, 1); (21, 20, 21, 22, 1)|]
579+
|> shouldEqual [|
580+
(3, 10, 3, 12, 1); (4, 10, 4, 15, 1); (5, 10, 5, 16, 1); (7, 11, 7, 15, 1);
581+
(8, 11, 8, 14, 1); (13, 12, 13, 15, 1); (14, 38, 14, 40, 1);
582+
(16, 12, 16, 18, 1); (17, 11, 17, 13, 1); (17, 18, 17, 22, 1);
583+
(18, 10, 18, 12, 0); (19, 15, 19, 17, 1); (19, 32, 19, 34, 1);
584+
(20, 15, 20, 17, 1); (21, 20, 21, 22, 1)
585+
|]
585586

586587
[<Test>]
587588
let ``Printf specifiers for triple quote interpolated strings`` () =

0 commit comments

Comments
 (0)