Skip to content

Fix for #18433 (internal error during xml comment processing) #18436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion src/Compiler/SyntaxTree/XmlDoc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions tests/FSharp.Compiler.ComponentTests/Language/XmlComments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,19 @@ module M =
|> withXmlCommentChecking
|> compile
|> withDiagnostics [ ]

// regression test for #18433
[<Fact>]
let OverrideXmlCommentsWithSameRange () =
Fs"""
module A
# 1
/// A is int
type A = {a: int}
# 1
/// B is int
type B = {b: int}
"""
|> withXmlCommentChecking
|> compile
|> shouldSucceed