Skip to content

Commit e55905e

Browse files
authored
Merge branch 'main' into vectorization
2 parents 4c62650 + 34dbfc1 commit e55905e

File tree

160 files changed

+7281
-118
lines changed

Some content is hidden

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

160 files changed

+7281
-118
lines changed

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

+3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
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+
* Allow `_` in `use!` bindings values (lift FS1228 restriction) ([PR #18487](https://github.com/dotnet/fsharp/pull/18487))
2829
* Make `[<CallerMemberName; Struct>]` combination work([PR #18444](https://github.com/dotnet/fsharp/pull/18444/))
30+
* Fix code completion considers types from own namespace non-imported ([PR #18518](https://github.com/dotnet/fsharp/issues/18518))
31+
* Code completion: fix getting qualifier expression in do statements in type decls ([PR #18524](https://github.com/dotnet/fsharp/pull/18524))
2932

3033
### Added
3134
* Added missing type constraints in FCS. ([PR #18241](https://github.com/dotnet/fsharp/pull/18241))

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

+1
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/Version.Details.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
</Dependency>
4343
</ProductDependencies>
4444
<ToolsetDependencies>
45-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25208.6">
45+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.25225.6">
4646
<Uri>https://github.com/dotnet/arcade</Uri>
47-
<Sha>aa61e8c20a869bcc994f8b29eb07d927d2bec6f4</Sha>
47+
<Sha>bfbc858ba868b60fffaf7b2150f1d2165b01e786</Sha>
4848
</Dependency>
4949
<!-- Intermediate is necessary for source build. -->
50-
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.25208.6">
50+
<Dependency Name="Microsoft.SourceBuild.Intermediate.arcade" Version="9.0.0-beta.25225.6">
5151
<Uri>https://github.com/dotnet/arcade</Uri>
52-
<Sha>aa61e8c20a869bcc994f8b29eb07d927d2bec6f4</Sha>
52+
<Sha>bfbc858ba868b60fffaf7b2150f1d2165b01e786</Sha>
5353
<SourceBuild RepoName="arcade" ManagedOnly="true" />
5454
</Dependency>
5555
<Dependency Name="optimization.windows_nt-x64.MIBC.Runtime" Version="1.0.0-prerelease.24462.2">

eng/build.sh

+1-1
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

+2-2
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

+1-1
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.25225.6",
2121
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
2222
}
2323
}

src/Compiler/Checking/CheckDeclarations.fs

+5-6
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

+1-2
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

+27-6
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/Driver/ParseAndCheckInputs.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1198,14 +1198,14 @@ let AddCheckResultsToTcState
11981198

11991199
// Add the implementation as to the implementation env
12001200
let tcImplEnv =
1201-
AddLocalRootModuleOrNamespace TcResultsSink.NoSink tcGlobals amap m tcImplEnv implFileSigType
1201+
AddLocalRootModuleOrNamespace tcGlobals amap m tcImplEnv implFileSigType
12021202

12031203
// Add the implementation as to the signature env (unless it had an explicit signature)
12041204
let tcSigEnv =
12051205
if hadSig then
12061206
tcState.tcsTcSigEnv
12071207
else
1208-
AddLocalRootModuleOrNamespace TcResultsSink.NoSink tcGlobals amap m tcState.tcsTcSigEnv implFileSigType
1208+
AddLocalRootModuleOrNamespace tcGlobals amap m tcState.tcsTcSigEnv implFileSigType
12091209

12101210
// Open the prefixPath for fsi.exe (tcImplEnv)
12111211
let tcImplEnv, openDecls =
@@ -1563,7 +1563,7 @@ let CheckOneInputWithCallback
15631563
let rootSigs = Zmap.add qualNameOfFile sigFileType tcState.tcsRootSigs
15641564

15651565
let tcSigEnv =
1566-
AddLocalRootModuleOrNamespace TcResultsSink.NoSink tcGlobals amap m tcState.tcsTcSigEnv sigFileType
1566+
AddLocalRootModuleOrNamespace tcGlobals amap m tcState.tcsTcSigEnv sigFileType
15671567

15681568
// Add the signature to the signature env (unless it had an explicit signature)
15691569
let ccuSigForFile = CombineCcuContentFragments [ sigFileType; tcState.tcsCcuSig ]

src/Compiler/FSComp.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1798,3 +1798,4 @@ featureDontWarnOnUppercaseIdentifiersInBindingPatterns,"Don't warn on uppercase
17981798
featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted"
17991799
featureSupportValueOptionsAsOptionalParameters,"Support ValueOption as valid type for optional member parameters"
18001800
featureSupportWarnWhenUnitPassedToObjArg,"Warn when unit is passed to a member accepting `obj` argument, e.g. `Method(o:obj)` will warn if called via `Method()`."
1801+
featureUseBangBindingValueDiscard,"Allows use! _ = ... in computation expressions"

src/Compiler/Facilities/LanguageFeatures.fs

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ type LanguageFeature =
9999
| DeprecatePlacesWhereSeqCanBeOmitted
100100
| SupportValueOptionsAsOptionalParameters
101101
| WarnWhenUnitPassedToObjArg
102+
| UseBangBindingValueDiscard
102103

103104
/// LanguageVersion management
104105
type LanguageVersion(versionText) =
@@ -229,6 +230,7 @@ type LanguageVersion(versionText) =
229230
LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted, previewVersion
230231
LanguageFeature.SupportValueOptionsAsOptionalParameters, previewVersion
231232
LanguageFeature.WarnWhenUnitPassedToObjArg, previewVersion
233+
LanguageFeature.UseBangBindingValueDiscard, previewVersion
232234
]
233235

234236
static let defaultLanguageVersion = LanguageVersion("default")
@@ -391,6 +393,7 @@ type LanguageVersion(versionText) =
391393
| LanguageFeature.DeprecatePlacesWhereSeqCanBeOmitted -> FSComp.SR.featureDeprecatePlacesWhereSeqCanBeOmitted ()
392394
| LanguageFeature.SupportValueOptionsAsOptionalParameters -> FSComp.SR.featureSupportValueOptionsAsOptionalParameters ()
393395
| LanguageFeature.WarnWhenUnitPassedToObjArg -> FSComp.SR.featureSupportWarnWhenUnitPassedToObjArg ()
396+
| LanguageFeature.UseBangBindingValueDiscard -> FSComp.SR.featureUseBangBindingValueDiscard ()
394397

395398
/// Get a version string associated with the given feature.
396399
static member GetFeatureVersionString feature =

src/Compiler/Facilities/LanguageFeatures.fsi

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type LanguageFeature =
9090
| DeprecatePlacesWhereSeqCanBeOmitted
9191
| SupportValueOptionsAsOptionalParameters
9292
| WarnWhenUnitPassedToObjArg
93+
| UseBangBindingValueDiscard
9394

9495
/// LanguageVersion management
9596
type LanguageVersion =

src/Compiler/Service/ServiceParseTreeWalk.fs

+2
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ module SyntaxTraversal =
10141014
let path = SyntaxNode.SynBinding b :: origPath
10151015

10161016
match b with
1017+
| SynBinding(kind = SynBindingKind.Do; expr = expr) -> traverseSynExpr path expr
1018+
10171019
| SynBinding(headPat = synPat; expr = synExpr; attributes = attributes; range = m) ->
10181020
[
10191021
yield! attributeApplicationDives path attributes

src/Compiler/pars.fsy

+19-3
Original file line numberDiff line numberDiff line change
@@ -3755,13 +3755,23 @@ atomicPattern:
37553755
{ SynPat.ArrayOrList(true, $2, lhs parseState) }
37563756

37573757
| UNDERSCORE
3758-
{ SynPat.Wild(lhs parseState) }
3758+
{ (* Underscore pattern ('_') is represented as SynPat.Wild
3759+
This wild pattern is used in all binding forms:
3760+
- let _ = ...
3761+
- use _ = ...
3762+
- let! _ = ...
3763+
- use! _ = ...
3764+
This ensures consistent representation of wildcard bindings in the AST *)
3765+
SynPat.Wild(lhs parseState) }
37593766

37603767
| QMARK ident
37613768
{ SynPat.OptionalVal($2, lhs parseState) }
37623769

37633770
| atomicPatternLongIdent %prec prec_atompat_pathop
3764-
{ let vis, lidwd = $1
3771+
{ (* This rule handles identifiers in patterns like 'use! __' *)
3772+
(* For simple identifiers (like '__'), it creates a SynPat.Named AST node *)
3773+
(* For complex paths (A.B.C) or uppercase ids, it calls mkSynPatMaybeVar *)
3774+
let vis, lidwd = $1
37653775
if not (isNilOrSingleton lidwd.LongIdent) || String.isLeadingIdentifierCharacterUpperCase (List.head lidwd.LongIdent).idText then
37663776
mkSynPatMaybeVar lidwd vis (lhs parseState)
37673777
else
@@ -4431,7 +4441,13 @@ declExpr:
44314441
SynExpr.YieldOrReturnFrom(($1, not $1), arbExpr ("yield!", mYieldAll), mYieldAll, trivia) }
44324442

44334443
| BINDER headBindingPattern EQUALS typedSequentialExprBlock IN opt_OBLOCKSEP moreBinders typedSequentialExprBlock %prec expr_let
4434-
{ let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5)
4444+
{ (* This rule handles the 'use!' and 'let!' binding expressions in computation expressions *)
4445+
(* The BINDER token represents keywords like 'use!' or 'let!' *)
4446+
(* headBindingPattern represents patterns in the binding:
4447+
- Underscore ('_') patterns are preserved as SynPat.Wild
4448+
- Named patterns ('__') are represented as SynPat.Named
4449+
- Identifiers (like 'value') are represented as SynPat.LongIdent *)
4450+
let spBind = DebugPointAtBinding.Yes(rhs2 parseState 1 5)
44354451
let mEquals = rhs parseState 3
44364452
let m = unionRanges (rhs parseState 1) $8.Range
44374453
let trivia: SynExprLetOrUseBangTrivia = { LetOrUseBangKeyword = rhs parseState 1 ; EqualsRange = Some mEquals }

src/Compiler/xlf/FSComp.txt.cs.xlf

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/xlf/FSComp.txt.de.xlf

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)