From cd07a7d1cde42d7cf1ed52d462c2a443aa96982d Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Wed, 2 Apr 2025 10:57:10 +0000 Subject: [PATCH 1/2] fix for 18433 --- src/Compiler/SyntaxTree/XmlDoc.fs | 3 ++- .../Language/XmlComments.fs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Compiler/SyntaxTree/XmlDoc.fs b/src/Compiler/SyntaxTree/XmlDoc.fs index a366a69a8a6..d4c4cada576 100644 --- a/src/Compiler/SyntaxTree/XmlDoc.fs +++ b/src/Compiler/SyntaxTree/XmlDoc.fs @@ -139,7 +139,8 @@ type XmlDocCollector() = let xmlDocBlock = struct (savedLines.Count - currentGrabPointCommentsCount, savedLines.Count - 1, false) - savedGrabPoints.Add(pos, xmlDocBlock) + // silently override duplicate grab points (which happen only when preceded by nonsensical line directives) + savedGrabPoints[pos] <- xmlDocBlock currentGrabPointCommentsCount <- 0 delayedGrabPoint <- ValueNone diff --git a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs index eed0e37e4db..47aee9362b7 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs @@ -242,3 +242,19 @@ module M = |> withXmlCommentChecking |> compile |> withDiagnostics [ ] + + // regression test for #18433 + [] + let OverrideXmlCommentsWithSameRange () = + Fs""" + module A + # 1 + /// A is int + type A = {a: int} + # 1 + /// B is int + type B = {b: int} + """ + |> withXmlCommentChecking + |> compile + |> shouldSucceed \ No newline at end of file From e6ced7a0ca8f45bb87ecdb9c2ca060b074b2bb28 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Wed, 2 Apr 2025 11:13:30 +0000 Subject: [PATCH 2/2] release note for #18436 --- docs/release-notes/.FSharp.Compiler.Service/9.0.300.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md index 86672567838..8893e4d237d 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -21,6 +21,7 @@ * 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)) * Fix #r nuget ..." downloads unneeded packages ([Issue #18231](https://github.com/dotnet/fsharp/issues/18231), [PR #18393](https://github.com/dotnet/fsharp/pull/18393)) * Reenable β-reduction and subsequent reoptimization of immediately-invoked F#-defined generic delegates. ([PR #18401](https://github.com/dotnet/fsharp/pull/18401)) +* Fixed [#18433](https://github.com/dotnet/fsharp/issues/18433), a rare case of an internal error in xml comment processing. ([PR #18436](https://github.com/dotnet/fsharp/pull/18436)) ### Added * Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241))