Skip to content

Commit 136c8b5

Browse files
authored
Merge branch 'main' into fix-10629
2 parents 15ec291 + 5a239f6 commit 136c8b5

File tree

201 files changed

+8287
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+8287
-292
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
* 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))
2626
* Fix confusing type inference error in task expression ([Issue #13789](https://github.com/dotnet/fsharp/issues/13789), [PR #18450](https://github.com/dotnet/fsharp/pull/18450))
2727
* Fix missing `null` highlighting in tooltips ([PR #18457](https://github.com/dotnet/fsharp/pull/18457))
28+
* Fix range of SynPat.Named doesn't include accessibility ([PR #18526](https://github.com/dotnet/fsharp/pull/18526))
29+
* Allow `_` in `use!` bindings values (lift FS1228 restriction) ([PR #18487](https://github.com/dotnet/fsharp/pull/18487))
2830
* Make `[<CallerMemberName; Struct>]` combination work([PR #18444](https://github.com/dotnet/fsharp/pull/18444/))
31+
* Fix code completion considers types from own namespace non-imported ([PR #18518](https://github.com/dotnet/fsharp/issues/18518))
32+
* Code completion: fix getting qualifier expression in do statements in type decls ([PR #18524](https://github.com/dotnet/fsharp/pull/18524))
33+
* Fixed: [#18441](https://github.com/dotnet/fsharp/issues/18441) FSI multi-emit unstable. ([PR #18465](https://github.com/dotnet/fsharp/pull/18465))
2934

3035
### Added
3136
* Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241))
@@ -37,6 +42,7 @@
3742
* Type parameter constraint `null` in generic code will now automatically imply `not struct` ([Issue #18320](https://github.com/dotnet/fsharp/issues/18320), [PR #18323](https://github.com/dotnet/fsharp/pull/18323))
3843
* Add a switch to determine whether to generate a default implementation body for overridden method when completing. [PR #18341](https://github.com/dotnet/fsharp/pull/18341)
3944
* Use a more accurate range for CE Combine methods. [PR #18394](https://github.com/dotnet/fsharp/pull/18394)
45+
* Enable TypeSubsumptionCache for IDE use. [PR #18499](https://github.com/dotnet/fsharp/pull/18499)
4046

4147

4248
### Changed

docs/release-notes/.Language/preview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Deprecate places where `seq` can be omitted. ([Language suggestion #1033](https://github.com/fsharp/fslang-suggestions/issues/1033), [PR #17772](https://github.com/dotnet/fsharp/pull/17772))
55
* Added type conversions cache, only enabled for compiler runs ([PR#17668](https://github.com/dotnet/fsharp/pull/17668))
66
* Support ValueOption + Struct attribute as optional parameter for methods ([Language suggestion #1136](https://github.com/fsharp/fslang-suggestions/issues/1136), [PR #18098](https://github.com/dotnet/fsharp/pull/18098))
7+
* Allow `_` in `use!` bindings values (lift FS1228 restriction) ([PR #18487](https://github.com/dotnet/fsharp/pull/18487))
78
* Warn when `unit` is passed to an `obj`-typed argument ([PR #18330](https://github.com/dotnet/fsharp/pull/18330))
89

910
### Fixed

eng/DotNetBuild.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<!-- When altering this file, include @dotnet/product-construction as a reviewer. -->
22
<Project>
33

4+
<!-- TODO: Remove this file when fsharp upgrades to Arcade 10 -->
45
<PropertyGroup>
56
<GitHubRepositoryName>fsharp</GitHubRepositoryName>
67
<SourceBuildManagedOnly>true</SourceBuildManagedOnly>
8+
<ReportPrebuiltUsage Condition="'$(DotNetBuildSourceOnly)' == 'true'">$(DotNetBuildOrchestrator)</ReportPrebuiltUsage>
9+
<SetUpSourceBuildIntermediateNupkgCache>false</SetUpSourceBuildIntermediateNupkgCache>
10+
<CreateIntermediatePackage>false</CreateIntermediatePackage>
711
</PropertyGroup>
812

913
<!--

eng/SourceBuildPrebuiltBaseline.xml

Lines changed: 0 additions & 33 deletions
This file was deleted.

eng/Version.Details.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
33
<ProductDependencies>
4-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="9.0.0-alpha.1.25223.3">
5-
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
6-
<Sha>19eb5ea4e5f9c4e5256843a92805c8c9e942207d</Sha>
7-
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
8-
</Dependency>
9-
<!-- Intermediate is necessary for source build. -->
10-
<Dependency Name="Microsoft.SourceBuild.Intermediate.msbuild" Version="17.13.25-preview-25214-09">
11-
<Uri>https://github.com/dotnet/msbuild</Uri>
12-
<Sha>7ad4e1c76585d0ed6e438da2d4f9394326934399</Sha>
13-
<SourceBuild RepoName="msbuild" ManagedOnly="true" />
14-
</Dependency>
154
<Dependency Name="Microsoft.Build" Version="17.13.25">
165
<Uri>https://github.com/dotnet/msbuild</Uri>
176
<Sha>7ad4e1c76585d0ed6e438da2d4f9394326934399</Sha>
@@ -42,15 +31,9 @@
4231
</Dependency>
4332
</ProductDependencies>
4433
<ToolsetDependencies>
45-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25208.6">
46-
<Uri>https://github.com/dotnet/arcade</Uri>
47-
<Sha>aa61e8c20a869bcc994f8b29eb07d927d2bec6f4</Sha>
48-
</Dependency>
49-
<!-- Intermediate is necessary for source build. -->
50-
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.25208.6">
34+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25255.5">
5135
<Uri>https://github.com/dotnet/arcade</Uri>
52-
<Sha>aa61e8c20a869bcc994f8b29eb07d927d2bec6f4</Sha>
53-
<SourceBuild RepoName="arcade" ManagedOnly="true" />
36+
<Sha>1cfa39f82d00b3659a3d367bc344241946e10681</Sha>
5437
</Dependency>
5538
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.24462.2">
5639
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-optimization</Uri>

eng/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function Test() {
226226
projectname="${projectname%.*}"
227227
testlogpath="$artifacts_dir/TestResults/$configuration/${projectname}_$targetframework.xml"
228228
args="test \"$testproject\" --no-restore --no-build -c $configuration -f $targetframework --test-adapter-path . --logger \"xunit;LogFilePath=$testlogpath\" --blame-hang-timeout 5minutes --results-directory $artifacts_dir/TestResults/$configuration -p:vstestusemsbuildoutput=false"
229-
args+=" -- xUnit.MaxParallelThreads=1"
229+
230230
"$DOTNET_INSTALL_DIR/dotnet" $args || exit $?
231231
}
232232

eng/common/core-templates/job/source-index-stage1.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
parameters:
22
runAsPublic: false
3-
sourceIndexUploadPackageVersion: 2.0.0-20240522.1
4-
sourceIndexProcessBinlogPackageVersion: 1.0.1-20240522.1
3+
sourceIndexUploadPackageVersion: 2.0.0-20250425.2
4+
sourceIndexProcessBinlogPackageVersion: 1.0.1-20250425.2
55
sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
66
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
77
preSteps: []

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"perl": "5.38.2.2"
1818
},
1919
"msbuild-sdks": {
20-
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25208.6",
20+
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25255.5",
2121
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
2222
}
2323
}

src/Compiler/Checking/CheckDeclarations.fs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ let AddNonLocalCcu g amap scopem env assemblyName (ccu: CcuThunk, internalsVisib
341341
env
342342

343343
/// Adjust the TcEnv to account for a fully processed "namespace" declaration in this file
344-
let AddLocalRootModuleOrNamespace tcSink g amap scopem env (moduleTy: ModuleOrNamespaceType) =
344+
let AddLocalRootModuleOrNamespace g amap scopem env (moduleTy: ModuleOrNamespaceType) =
345345
// Compute the top-rooted module or namespace references
346346
let modrefs = moduleTy.ModuleAndNamespaceDefinitions |> List.map mkLocalModuleRef
347347
// Compute the top-rooted type definitions
@@ -350,7 +350,6 @@ let AddLocalRootModuleOrNamespace tcSink g amap scopem env (moduleTy: ModuleOrNa
350350
let env = { env with
351351
eNameResEnv = if isNil tcrefs then env.eNameResEnv else AddTyconRefsToNameEnv BulkAdd.No false g amap env.eAccessRights scopem true env.eNameResEnv tcrefs
352352
eUngeneralizableItems = addFreeItemOfModuleTy moduleTy env.eUngeneralizableItems }
353-
CallEnvSink tcSink (scopem, env.NameEnv, env.eAccessRights)
354353
env
355354

356355
/// Inside "namespace X.Y.Z" there is an implicit open of "X.Y.Z"
@@ -4978,7 +4977,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE
49784977
CallNameResolutionSink cenv.tcSink (moduleEntity.Range, env.NameEnv, item, emptyTyparInst, ItemOccurrence.Binding, env.AccessRights))
49794978

49804979
// For 'namespace rec' and 'module rec' we add the thing being defined
4981-
let envNS = if isRec then AddLocalRootModuleOrNamespace cenv.tcSink g cenv.amap m envNS modTyRoot else envNS
4980+
let envNS = if isRec then AddLocalRootModuleOrNamespace g cenv.amap m envNS modTyRoot else envNS
49824981
let nsInfo = Some (modulNSOpt, envNS.eModuleOrNamespaceTypeAccumulator)
49834982
let mutRecNSInfo = if isRec then nsInfo else None
49844983

@@ -4990,7 +4989,7 @@ let rec TcSignatureElementNonMutRec (cenv: cenv) parent typeNames endm (env: TcE
49904989
if isNil enclosingNamespacePath then
49914990
envAtEnd
49924991
else
4993-
let env = AddLocalRootModuleOrNamespace cenv.tcSink g cenv.amap m env modTyRoot
4992+
let env = AddLocalRootModuleOrNamespace g cenv.amap m env modTyRoot
49944993

49954994
// If the namespace is an interactive fragment e.g. FSI_0002, then open FSI_0002 in the subsequent environment.
49964995
let env, _openDecls =
@@ -5440,7 +5439,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem
54405439
CallNameResolutionSink cenv.tcSink (moduleEntity.Range, env.NameEnv, item, emptyTyparInst, ItemOccurrence.Binding, env.AccessRights))
54415440

54425441
// For 'namespace rec' and 'module rec' we add the thing being defined
5443-
let envNS = if isRec then AddLocalRootModuleOrNamespace cenv.tcSink g cenv.amap m envNS modTyRoot else envNS
5442+
let envNS = if isRec then AddLocalRootModuleOrNamespace g cenv.amap m envNS modTyRoot else envNS
54445443
let nsInfo = Some (modulNSOpt, envNS.eModuleOrNamespaceTypeAccumulator)
54455444
let mutRecNSInfo = if isRec then nsInfo else None
54465445

@@ -5453,7 +5452,7 @@ let rec TcModuleOrNamespaceElementNonMutRec (cenv: cenv) parent typeNames scopem
54535452
if isNil enclosingNamespacePath then
54545453
envAtEnd, []
54555454
else
5456-
let env = AddLocalRootModuleOrNamespace cenv.tcSink g cenv.amap m env modTyRoot
5455+
let env = AddLocalRootModuleOrNamespace g cenv.amap m env modTyRoot
54575456

54585457
// If the namespace is an interactive fragment e.g. FSI_0002, then open FSI_0002 in the subsequent environment
54595458
let env, openDecls =

src/Compiler/Checking/CheckDeclarations.fsi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ open FSharp.Compiler.TcGlobals
1313
open FSharp.Compiler.Text
1414
open FSharp.Compiler.TypedTree
1515

16-
val AddLocalRootModuleOrNamespace:
17-
TcResultsSink -> TcGlobals -> ImportMap -> range -> TcEnv -> ModuleOrNamespaceType -> TcEnv
16+
val AddLocalRootModuleOrNamespace: TcGlobals -> ImportMap -> range -> TcEnv -> ModuleOrNamespaceType -> TcEnv
1817

1918
val CreateInitialTcEnv:
2019
TcGlobals * ImportMap * range * assemblyName: string * (CcuThunk * string list * string list) list ->

src/Compiler/Checking/Expressions/CheckComputationExpressions.fs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// with generalization at appropriate points.
55
module internal FSharp.Compiler.CheckComputationExpressions
66

7+
open FSharp.Compiler.TcGlobals
78
open Internal.Utilities.Library
89
open FSharp.Compiler.AccessibilityLogic
910
open FSharp.Compiler.AttributeChecking
@@ -1783,12 +1784,33 @@ let rec TryTranslateComputationExpression
17831784
if ceenv.isQuery then
17841785
error (Error(FSComp.SR.tcBindMayNotBeUsedInQueries (), mBind))
17851786

1786-
match pat, andBangs with
1787-
| (SynPat.Named(ident = SynIdent(id, _); isThisVal = false) | SynPat.LongIdent(longDotId = SynLongIdent(id = [ id ]))), [] ->
1787+
match andBangs with
1788+
| [] ->
17881789
// Valid pattern case - handle with Using + Bind
17891790
requireBuilderMethod "Using" mBind cenv ceenv.env ceenv.ad ceenv.builderTy mBind
17901791
requireBuilderMethod "Bind" mBind cenv ceenv.env ceenv.ad ceenv.builderTy mBind
17911792

1793+
let supportsUseBangBindingValueDiscard =
1794+
ceenv.cenv.g.langVersion.SupportsFeature LanguageFeature.UseBangBindingValueDiscard
1795+
1796+
// use! x = ...
1797+
// use! (x) = ...
1798+
// use! (__) = ...
1799+
// use! _ = ...
1800+
// use! (_) = ...
1801+
let rec extractIdentifierFromPattern pat =
1802+
match pat with
1803+
| SynPat.Named(ident = SynIdent(id, _); isThisVal = false) -> id, pat
1804+
| SynPat.LongIdent(longDotId = SynLongIdent(id = [ id ])) -> id, pat
1805+
| SynPat.Wild(m) when supportsUseBangBindingValueDiscard ->
1806+
// To properly call the Using(disposable) CE member, we need to convert the wildcard to a SynPat.Named
1807+
let tmpIdent = mkSynId m "_"
1808+
tmpIdent, SynPat.Named(SynIdent(tmpIdent, None), false, None, m)
1809+
| SynPat.Paren(pat = pat) -> extractIdentifierFromPattern pat
1810+
| _ -> error (Error(FSComp.SR.tcInvalidUseBangBinding (), pat.Range))
1811+
1812+
let ident, pat = extractIdentifierFromPattern pat
1813+
17921814
let bindExpr =
17931815
let consumeExpr =
17941816
SynExpr.MatchLambda(
@@ -1809,14 +1831,14 @@ let rec TryTranslateComputationExpression
18091831
)
18101832

18111833
let consumeExpr =
1812-
mkSynCall "Using" mBind [ SynExpr.Ident id; consumeExpr ] ceenv.builderValName
1834+
mkSynCall "Using" mBind [ SynExpr.Ident ident; consumeExpr ] ceenv.builderValName
18131835

18141836
let consumeExpr =
18151837
SynExpr.MatchLambda(
18161838
false,
18171839
mBind,
18181840
[
1819-
SynMatchClause(pat, None, consumeExpr, id.idRange, DebugPointAtTarget.No, SynMatchClauseTrivia.Zero)
1841+
SynMatchClause(pat, None, consumeExpr, ident.idRange, DebugPointAtTarget.No, SynMatchClauseTrivia.Zero)
18201842
],
18211843
DebugPointAtBinding.NoneAtInvisible,
18221844
mBind
@@ -1829,8 +1851,7 @@ let rec TryTranslateComputationExpression
18291851
|> addBindDebugPoint spBind
18301852

18311853
Some(translatedCtxt bindExpr)
1832-
| _pat, [] -> error (Error(FSComp.SR.tcInvalidUseBangBinding (), mBind))
1833-
| _pat, _ands ->
1854+
| _ ->
18341855
// Has andBangs
18351856
let m =
18361857
match andBangs with

src/Compiler/Checking/TypeRelations.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let TypesFeasiblyEquivStripMeasures g amap m ty1 ty2 =
102102
TypesFeasiblyEquivalent true 0 g amap m ty1 ty2
103103

104104
let inline TryGetCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key =
105-
if g.compilationMode = CompilationMode.OneOff && g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
105+
if g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
106106
match amap.TypeSubsumptionCache.TryGetValue(key) with
107107
| true, subsumes ->
108108
ValueSome subsumes
@@ -112,8 +112,8 @@ let inline TryGetCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key =
112112
ValueNone
113113

114114
let inline UpdateCachedTypeSubsumption (g: TcGlobals) (amap: ImportMap) key subsumes : unit =
115-
if g.compilationMode = CompilationMode.OneOff && g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
116-
amap.TypeSubsumptionCache[key] <- subsumes
115+
if g.langVersion.SupportsFeature LanguageFeature.UseTypeSubsumptionCache then
116+
amap.TypeSubsumptionCache.TryAdd(key, subsumes) |> ignore
117117

118118
/// The feasible coercion relation. Part of the language spec.
119119
let rec TypeFeasiblySubsumesType ndeep (g: TcGlobals) (amap: ImportMap) m (ty1: TType) (canCoerce: CanCoerce) (ty2: TType) =
@@ -125,7 +125,7 @@ let rec TypeFeasiblySubsumesType ndeep (g: TcGlobals) (amap: ImportMap) m (ty1:
125125
let ty2 = stripTyEqns g ty2
126126

127127
// Check if language feature supported
128-
let key = TTypeCacheKey.FromStrippedTypes (ty1, ty2, canCoerce, g)
128+
let key = TTypeCacheKey.FromStrippedTypes (ty1, ty2, canCoerce)
129129

130130
match TryGetCachedTypeSubsumption g amap key with
131131
| ValueSome subsumes ->

0 commit comments

Comments
 (0)