Skip to content

Commit 6a93b99

Browse files
dotnet-botT-GropsfinakiMartin521vzarytovskii
authored
Merge main to release/dev17.13 (#18131)
* Backport :: Bugfix :: Support `ldelem.u8`, `ldelem.u` opcode aliases (#18081) (#18096) * Streamlining test deps a bit (#18022) * Streamlining test deps a bit * up * Format ILVerify output a bit (#18120) * fix for race condition in FileIndex.fileIndexOfFile (#18008) * fix for race condition in FileIndex.fileIndexOfFile * fantomas * fixed ilverify baselines (just a single line number changed) * add release notes entry * FileToIndex: Added unlocked read so that lock is entered for new files only * update ilverify baselines (changed line numbers only) * Fix ILVerify --------- Co-authored-by: Petr <[email protected]> Co-authored-by: Vlad Zarytovskii <[email protected]> * Update F# build version to 200 * Fix how much is trimmed from an interp string part (#18123) * Fix how much is trimmed from an interp string part Only trim last 2 characters if they are "%s" and the '%' is not escaped * Add release note --------- Co-authored-by: Adam Boniecki <[email protected]> * Sink: report SynPat.ArrayOrList type (#18127) --------- Co-authored-by: Tomas Grosup <[email protected]> Co-authored-by: Petr <[email protected]> Co-authored-by: Martin <[email protected]> Co-authored-by: Vlad Zarytovskii <[email protected]> Co-authored-by: Adam Boniecki <[email protected]> Co-authored-by: Adam Boniecki <[email protected]> Co-authored-by: Alex Berezhnykh <[email protected]> Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent a6fc9bb commit 6a93b99

File tree

15 files changed

+82
-43
lines changed

15 files changed

+82
-43
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
* Fix locals allocating for the special `copyOfStruct` defensive copy ([PR #18025](https://github.com/dotnet/fsharp/pull/18025))
1616
* Fix lowering of computed array expressions when the expression consists of a simple mapping from a `uint64` or `unativeint` array. [PR #18081](https://github.com/dotnet/fsharp/pull/18081)
1717
* Add missing nullable-metadata for C# consumers of records,exceptions and DU subtypes generated from F# code. [PR #18079](https://github.com/dotnet/fsharp/pull/18079)
18-
18+
* Fix a race condition in file book keeping in the compiler service ([#18008](https://github.com/dotnet/fsharp/pull/18008))
19+
* Fix trimming '%' characters when lowering interpolated string to a concat call [PR #18123](https://github.com/dotnet/fsharp/pull/18123)
1920

2021
### Added
2122

@@ -25,6 +26,7 @@
2526
* Added type conversions cache, only enabled for compiler runs, guarded by language version preview ([PR #17668](https://github.com/dotnet/fsharp/pull/17668))
2627
* Added project property ParallelCompilation which turns on graph based type checking, parallel ILXGen and parallel optimization. By default on for users of langversion=preview ([PR #17948](https://github.com/dotnet/fsharp/pull/17948))
2728
* Adding warning when consuming generic method returning T|null for types not supporting nullness (structs,anons,tuples) ([PR #18057](https://github.com/dotnet/fsharp/pull/18057))
29+
* Sink: report SynPat.ArrayOrList type ([PR #18127](https://github.com/dotnet/fsharp/pull/18127))
2830

2931
### Changed
3032

eng/Versions.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
<MicrosoftNETCoreAppRefVersion>3.1.0</MicrosoftNETCoreAppRefVersion>
185185
<MicrosoftNETCoreILDAsmVersion>5.0.0-preview.7.20364.11</MicrosoftNETCoreILDAsmVersion>
186186
<MicrosoftNETCoreILAsmVersion>5.0.0-preview.7.20364.11</MicrosoftNETCoreILAsmVersion>
187-
<MicrosoftNETTestSdkVersion>17.4.0</MicrosoftNETTestSdkVersion>
187+
<MicrosoftNETTestSdkVersion>17.11.1</MicrosoftNETTestSdkVersion>
188188
<NewtonsoftJsonVersion>13.0.3</NewtonsoftJsonVersion>
189189
<RoslynToolsSignToolVersion>1.0.0-beta2-dev3</RoslynToolsSignToolVersion>
190190
<StreamJsonRpcVersion>2.18.48</StreamJsonRpcVersion>

src/Compiler/Checking/CheckPatterns.fs

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ and TcPat warnOnUpper (cenv: cenv) env valReprInfo vFlags (patEnv: TcPatLinearEn
313313
TcPat warnOnUpper cenv env None vFlags patEnv ty p
314314

315315
| SynPat.ArrayOrList (isArray, args, m) ->
316+
CallExprHasTypeSink cenv.tcSink (m, env.NameEnv, ty, env.AccessRights)
316317
TcPatArrayOrList warnOnUpper cenv env vFlags patEnv ty isArray args m
317318

318319
| SynPat.Record (flds, m) ->

src/Compiler/Checking/Expressions/CheckExpressions.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ let (|WithTrailingStringSpecifierRemoved|) (s: string) =
174174
let i = s.AsSpan(0, s.Length - 2).LastIndexOfAnyExcept '%'
175175
let diff = s.Length - 2 - i
176176
if diff &&& 1 <> 0 then
177-
s[..i]
177+
s[..s.Length - 3]
178178
else
179179
s
180180
else

src/Compiler/Utilities/range.fs

+37-32
Original file line numberDiff line numberDiff line change
@@ -196,38 +196,43 @@ type FileIndexTable() =
196196
match fileToIndexTable.TryGetValue filePath with
197197
| true, idx -> idx
198198
| _ ->
199-
200-
// Try again looking for a normalized entry.
201-
let normalizedFilePath =
202-
if normalize then
203-
FileSystem.NormalizePathShim filePath
204-
else
205-
filePath
206-
207-
match fileToIndexTable.TryGetValue normalizedFilePath with
208-
| true, idx ->
209-
// Record the non-normalized entry if necessary
210-
if filePath <> normalizedFilePath then
211-
lock fileToIndexTable (fun () -> fileToIndexTable[filePath] <- idx)
212-
213-
// Return the index
214-
idx
215-
216-
| _ ->
217-
lock fileToIndexTable (fun () ->
218-
// Get the new index
219-
let idx = indexToFileTable.Count
220-
221-
// Record the normalized entry
222-
indexToFileTable.Add normalizedFilePath
223-
fileToIndexTable[normalizedFilePath] <- idx
224-
225-
// Record the non-normalized entry if necessary
226-
if filePath <> normalizedFilePath then
227-
fileToIndexTable[filePath] <- idx
228-
229-
// Return the index
230-
idx)
199+
// If a write operation can happen, we have to lock the whole read-check-write to avoid race conditions
200+
lock fileToIndexTable
201+
<| fun () ->
202+
match fileToIndexTable.TryGetValue filePath with
203+
| true, idx -> idx
204+
| _ ->
205+
206+
// Try again looking for a normalized entry.
207+
let normalizedFilePath =
208+
if normalize then
209+
FileSystem.NormalizePathShim filePath
210+
else
211+
filePath
212+
213+
match fileToIndexTable.TryGetValue normalizedFilePath with
214+
| true, idx ->
215+
// Record the non-normalized entry if necessary
216+
if filePath <> normalizedFilePath then
217+
fileToIndexTable[filePath] <- idx
218+
219+
// Return the index
220+
idx
221+
222+
| _ ->
223+
// Get the new index
224+
let idx = indexToFileTable.Count
225+
226+
// Record the normalized entry
227+
indexToFileTable.Add normalizedFilePath
228+
fileToIndexTable[normalizedFilePath] <- idx
229+
230+
// Record the non-normalized entry if necessary
231+
if filePath <> normalizedFilePath then
232+
fileToIndexTable[filePath] <- idx
233+
234+
// Return the index
235+
idx
231236

232237
member t.IndexToFile n =
233238
if n < 0 then

tests/EndToEndBuildTests/BasicProvider/BasicProvider.Tests/BasicProvider.Tests.fsproj

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
<PackagePath>content\myfiles\</PackagePath>
2222
</Content>
2323
<PackageReference Include="BasicProvider" Version="1.0.0" />
24-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
2524
</ItemGroup>
2625

2726
<Target Name="RemovePackagesFromCache" BeforeTargets="Restore">

tests/EndToEndBuildTests/ComboProvider/ComboProvider.Tests/ComboProvider.Tests.fsproj

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
</None>
1919

2020
<PackageReference Include="ComboProvider" Version="1.0.0" />
21-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
2221
</ItemGroup>
2322

2423
<Target Name="RemovePackagesFromCache" BeforeTargets="Restore">

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@
317317
<Compile Include="Miscellaneous\MigratedOverloadTests.fs" />
318318
<Compile Include="Miscellaneous\MigratedTypeCheckTests.fs" />
319319
<Compile Include="Miscellaneous\GraphTests.fs" />
320+
<Compile Include="Miscellaneous\FileIndex.fs" />
320321
<Compile Include="Signatures\TestHelpers.fs" />
321322
<Compile Include="Signatures\ModuleOrNamespaceTests.fs" />
322323
<Compile Include="Signatures\RecordTests.fs" />

tests/FSharp.Compiler.ComponentTests/Language/InterpolatedStringsTests.fs

+11
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ type Foo () =
130130
|> compile
131131
|> shouldSucceed
132132

133+
[<Fact>]
134+
let ``Percent signs and format specifiers with string expression`` () =
135+
Fsx """
136+
let x = "abc"
137+
let s = $"%%%s{x}%%"
138+
printfn "%s" s
139+
"""
140+
|> compileExeAndRun
141+
|> shouldSucceed
142+
|> withStdOutContains "%abc%"
143+
133144
[<Theory>]
134145
// Test different number of interpolated string parts
135146
[<InlineData("$\"\"\"abc{\"d\"}e\"\"\"")>]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Miscellaneous.FileIndex
2+
3+
open FSharp.Compiler.Text
4+
open System.Threading.Tasks
5+
open Xunit
6+
7+
// This is a regression test for a bug that existed in FileIndex.fileIndexOfFile
8+
[<Fact>]
9+
let NoRaceCondition() =
10+
let parallelOptions = ParallelOptions()
11+
let mutable count = 10000
12+
while count > 0 do
13+
let file = $"test{count}.fs"
14+
let files = Array.create 2 file
15+
let indices = Array.create 2 -1
16+
let getFileIndex i = indices[i] <- FileIndex.fileIndexOfFile files[i]
17+
Parallel.For(0, files.Length, parallelOptions, getFileIndex) |> ignore
18+
if indices[0] <> indices[1] then
19+
Assert.Fail $"Found different indices: {indices[0]} and {indices[1]}"
20+
count <- count - 1
21+

tests/ILVerify/ilverify.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ foreach ($project in $projects.Keys) {
162162
} else {
163163
Write-Host "ILverify output does not match baseline, differences:"
164164

165-
$cmp | Format-Table | Out-String | Write-Host
165+
$cmp | Format-Table -AutoSize -Wrap | Out-String | Write-Host
166166

167167
# Update baselines if TEST_UPDATE_BSL is set to 1
168168
if ($env:TEST_UPDATE_BSL -eq "1") {
@@ -185,4 +185,4 @@ if ($failed) {
185185
exit 1
186186
}
187187

188-
exit 0
188+
exit 0

tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_net9.0.bsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.IL::parseILVersion(string)][offset 0x0000000B][found Char] Unexpected type on the stack.
6060
[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.IL::parseILVersion(string)][offset 0x00000021][found Char] Unexpected type on the stack.
6161
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$FSharp.Compiler.DiagnosticsLogger::.cctor()][offset 0x000000CD][found Char] Unexpected type on the stack.
62-
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@543::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
62+
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@548::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
6363
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000037][found Char] Unexpected type on the stack.
6464
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000043][found Char] Unexpected type on the stack.
6565
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$Internal.Utilities.XmlAdapters::.cctor()][offset 0x0000000A][found Char] Unexpected type on the stack.

tests/ILVerify/ilverify_FSharp.Compiler.Service_Debug_netstandard2.0.bsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
[IL]: Error [StackUnexpected]: : Internal.Utilities.FSharpEnvironment+probePathForDotnetHost@321::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000028][found Char] Unexpected type on the stack.
8585
[IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.SimulatedMSBuildReferenceResolver+Pipe #6 input at line 68@68::FSharp.Compiler.CodeAnalysis.ILegacyReferenceResolver.Resolve([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyResolutionEnvironment, [S.P.CoreLib]System.Tuple`2<string,string>[], string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<string>, string, string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<string>, string, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.Unit>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool,Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.Unit>>>)][offset 0x0000034D][found Char] Unexpected type on the stack.
8686
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$FSharp.Compiler.DiagnosticsLogger::.cctor()][offset 0x000000CD][found Char] Unexpected type on the stack.
87-
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@543::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
87+
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@548::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
8888
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000037][found Char] Unexpected type on the stack.
8989
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000043][found Char] Unexpected type on the stack.
9090
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$Internal.Utilities.XmlAdapters::.cctor()][offset 0x0000000A][found Char] Unexpected type on the stack.

tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_net9.0.bsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.IL::parseILVersion(string)][offset 0x0000000B][found Char] Unexpected type on the stack.
8686
[IL]: Error [StackUnexpected]: : FSharp.Compiler.AbstractIL.IL::parseILVersion(string)][offset 0x00000021][found Char] Unexpected type on the stack.
8787
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$FSharp.Compiler.DiagnosticsLogger::.cctor()][offset 0x000000B6][found Char] Unexpected type on the stack.
88-
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@543::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
88+
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@548::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
8989
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000035][found Char] Unexpected type on the stack.
9090
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000041][found Char] Unexpected type on the stack.
9191
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$Internal.Utilities.XmlAdapters::.cctor()][offset 0x0000000A][found Char] Unexpected type on the stack.

tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
[IL]: Error [StackUnexpected]: : Internal.Utilities.FSharpEnvironment::probePathForDotnetHost@320([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x0000002A][found Char] Unexpected type on the stack.
112112
[IL]: Error [StackUnexpected]: : FSharp.Compiler.CodeAnalysis.SimulatedMSBuildReferenceResolver+SimulatedMSBuildResolver@68::FSharp.Compiler.CodeAnalysis.ILegacyReferenceResolver.Resolve([FSharp.Compiler.Service]FSharp.Compiler.CodeAnalysis.LegacyResolutionEnvironment, [S.P.CoreLib]System.Tuple`2<string,string>[], string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<string>, string, string, [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<string>, string, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.Unit>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<bool,Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.FSharpFunc`2<string,Microsoft.FSharp.Core.Unit>>>)][offset 0x000002F5][found Char] Unexpected type on the stack.
113113
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$FSharp.Compiler.DiagnosticsLogger::.cctor()][offset 0x000000B6][found Char] Unexpected type on the stack.
114-
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@543::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
114+
[IL]: Error [CallVirtOnValueType]: : FSharp.Compiler.Text.RangeModule+comparer@548::System.Collections.Generic.IEqualityComparer<FSharp.Compiler.Text.Range>.GetHashCode([FSharp.Compiler.Service]FSharp.Compiler.Text.Range)][offset 0x00000002] Callvirt on a value type method.
115115
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000035][found Char] Unexpected type on the stack.
116116
[IL]: Error [StackUnexpected]: : Internal.Utilities.PathMapModule::applyDir([FSharp.Compiler.Service]Internal.Utilities.PathMap, string)][offset 0x00000041][found Char] Unexpected type on the stack.
117117
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$Internal.Utilities.XmlAdapters::.cctor()][offset 0x0000000A][found Char] Unexpected type on the stack.

0 commit comments

Comments
 (0)