Skip to content
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/11.0.100.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Fixed

* Deduplicate format specifier locations in computation expressions so editor tooling no longer reports duplicate entries for the same `%` specifier. ([Issue #16419](https://github.com/dotnet/fsharp/issues/16419), [PR #19791](https://github.com/dotnet/fsharp/pull/19791))
* Reject non-function bindings for single-case and partial active pattern names with FS1209, matching the existing multi-case behavior. ([PR #19763](https://github.com/dotnet/fsharp/pull/19763))
* Fix FS0421 "The address of the variable cannot be used at this point" incorrectly raised for the discard pattern `let _ = &expr` when `let x = &expr` compiles. ([Issue #18841](https://github.com/dotnet/fsharp/issues/18841), [PR #19811](https://github.com/dotnet/fsharp/pull/19811))
* Honor `--nowarn` and `--warnaserror` for warnings emitted during command-line option parsing ([Issue #19576](https://github.com/dotnet/fsharp/issues/19576), [PR #19776](https://github.com/dotnet/fsharp/pull/19776))
Expand Down
5 changes: 4 additions & 1 deletion src/Compiler/Checking/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,8 @@ type TcResultsSinkImpl(tcGlobals, ?sourceText: ISourceText) =
let capturedOpenDeclarations = ResizeArray<OpenDeclaration>()
let capturedFormatSpecifierLocations = ResizeArray<_>()

let capturedFormatSpecifierRanges = HashSet<range>()

let capturedNameResolutionIdentifiers =
HashSet<pos * string>
{ new IEqualityComparer<_> with
Expand Down Expand Up @@ -2289,7 +2291,8 @@ type TcResultsSinkImpl(tcGlobals, ?sourceText: ISourceText) =
capturedMethodGroupResolutions.Add(CapturedNameResolution(itemMethodGroup, [], occurrenceType, nenv, ad, m))

member sink.NotifyFormatSpecifierLocation(m, numArgs) =
capturedFormatSpecifierLocations.Add((m, numArgs))
if capturedFormatSpecifierRanges.Add(m) then
capturedFormatSpecifierLocations.Add((m, numArgs))

member sink.NotifyRelatedSymbolUse(m, item, kind) =
if allowedRange m then
Expand Down
13 changes: 13 additions & 0 deletions tests/FSharp.Compiler.Service.Tests/EditorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ let _ = debug "[LanguageService] Type checking fails for '%s' with content=%A an
(4, 82, 4, 84, 1);
(4, 108, 4, 110, 1)|]

[<Fact>]
let ``Format specifier locations not duplicated in CE`` () =
let input = "let _ = seq { sprintf \"%d\" 1 }"
let file = "/home/user/Test.fsx"
let _parseResult, typeCheckResults = parseAndCheckScript(file, input)

let locations = typeCheckResults.GetFormatSpecifierLocationsAndArity()
let percentD =
locations
|> Array.filter (fun (r, _) -> r.StartColumn = 23)

Assert.Equal(1, percentD.Length)

#if ASSUME_PREVIEW_FSHARP_CORE
[<Fact>]
let ``Printf specifiers for regular and verbatim interpolated strings`` () =
Expand Down
Loading