Skip to content

Commit d43a46b

Browse files
Martin521psfinaki
andauthored
Fix duplicate parse errors for GetBackgroundCheckResultsForFileInProject (#18380)
* fix duplicate parse errors for GetBackgroundCheckResultsForFileInProject * added release notes --------- Co-authored-by: Petr <[email protected]>
1 parent d382d4a commit d43a46b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.300.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Fix "type inference problem too complicated" for SRTP with T:null and T:struct dummy constraint([Issue #18288](https://github.com/dotnet/fsharp/issues/18288), [PR #18345](https://github.com/dotnet/fsharp/pull/18345))
1717
* Fix for missing parse diagnostics in TransparentCompiler.ParseAndCheckProject ([PR #18366](https://github.com/dotnet/fsharp/pull/18366))
1818
* Miscellanous parentheses analyzer fixes. ([PR #18350](https://github.com/dotnet/fsharp/pull/18350))
19+
* Fix duplicate parse error reporting for GetBackgroundCheckResultsForFileInProject ([Issue #18379](https://github.com/dotnet/fsharp/issues/18379) [PR #18380](https://github.com/dotnet/fsharp/pull/18380))
1920
* Fix MethodDefNotFound when compiling code invoking delegate with option parameter ([Issue #5171](https://github.com/dotnet/fsharp/issues/5171), [PR #18385](https://github.com/dotnet/fsharp/pull/18385))
2021

2122
### Added

src/Compiler/Service/BackgroundCompiler.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ type internal BackgroundCompiler
10711071
Some options,
10721072
Array.ofList tcDependencyFiles,
10731073
creationDiags,
1074-
parseResults.Diagnostics,
1074+
[||],
10751075
tcDiagnostics,
10761076
keepAssemblyContents,
10771077
Option.get latestCcuSigForFile,

tests/FSharp.Compiler.Service.Tests/ExprTests.fs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,19 +3526,29 @@ let ``Test NoWarn HashDirective`` () =
35263526

35273527
wholeProjectResults.Diagnostics.Length |> shouldEqual 0
35283528

3529-
module internal SourceForTrcParseErrors =
3530-
3531-
let fileSource1 = """
3529+
let private sourceForParseError = """
35323530
module N.M
35333531
#nowarn 0xy
35343532
()
35353533
"""
35363534

35373535
[<Fact>]
3538-
let ``TrcParseErrors`` () =
3539-
let options = createProjectOptions [SourceForTrcParseErrors.fileSource1] []
3536+
let ``RegressionTestForMissingParseError(TransparentCompiler)`` () =
3537+
let options = createProjectOptions [sourceForParseError] []
35403538
let exprChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=CompilerAssertHelpers.UseTransparentCompiler)
35413539
let wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate
35423540
wholeProjectResults.Diagnostics.Length |> shouldEqual 1
35433541
wholeProjectResults.Diagnostics.[0].ErrorNumber |> shouldEqual 1156
35443542
wholeProjectResults.Diagnostics.[0].Range.StartLine |> shouldEqual 3
3543+
3544+
[<Fact>]
3545+
let ``RegressionTestForDuplicateParseError(BackgroundCompiler)`` () =
3546+
let options = createProjectOptions [sourceForParseError] []
3547+
let exprChecker = FSharpChecker.Create(keepAssemblyContents=true, useTransparentCompiler=CompilerAssertHelpers.UseTransparentCompiler)
3548+
let sourceName = options.SourceFiles[0]
3549+
let _wholeProjectResults = exprChecker.ParseAndCheckProject(options) |> Async.RunImmediate
3550+
let _, checkResults = exprChecker.GetBackgroundCheckResultsForFileInProject(sourceName, options) |> Async.RunImmediate
3551+
checkResults.Diagnostics.Length |> shouldEqual 1
3552+
checkResults.Diagnostics.[0].ErrorNumber |> shouldEqual 1156
3553+
checkResults.Diagnostics.[0].Range.StartLine |> shouldEqual 3
3554+

0 commit comments

Comments
 (0)