Skip to content
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

Merge main to release/dev17.8 #15855

Merged
merged 11 commits into from
Aug 25, 2023
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
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.23414.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="8.0.0-alpha.1.23421.1">
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
<Sha>45f5554ac6813e1e155c47fd80ec146c684f65e8</Sha>
<Sha>f4903e46459e0348e3793055dd8b68b8b0264034</Sha>
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceBuild.Intermediate.msbuild" Version="17.7.0-preview-23217-02">
Expand All @@ -29,9 +29,9 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23419.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23422.1">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>385129cbc980a515ddee2fa56f6b16f3183ed9bc</Sha>
<Sha>4d9945d230fdd8324ce16a31c7dbd74e27a0fc9b</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23418.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
Expand Down
Binary file modified eng/common/loc/P22DotNetHtmlLocalization.lss
Binary file not shown.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"perl": "5.38.0.1"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23419.1",
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23422.1",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23255.2"
}
}
6 changes: 4 additions & 2 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4049,8 +4049,10 @@ module TcDeclarations =
if tcref.TyparsNoRange.Length = synTypars.Length then
(tcref.TyparsNoRange, synTypars)
||> List.zip
|> List.iter (fun (typar, SynTyparDecl.SynTyparDecl (typar = SynTypar (ident = untypedIdent))) ->
typar.SetIdent(untypedIdent)
|> List.iter (fun (typar, SynTyparDecl.SynTyparDecl (typar = tp)) ->
let (SynTypar(ident = untypedIdent; staticReq = sr)) = tp
if typar.StaticReq = sr then
typar.SetIdent(untypedIdent)
)

res
Expand Down
26 changes: 15 additions & 11 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5777,10 +5777,6 @@ and TcExprUndelayed (cenv: cenv) (overallTy: OverallTy) env tpenv (synExpr: SynE
| SynExpr.LetOrUseBang (range = m) ->
error(Error(FSComp.SR.tcConstructRequiresComputationExpression(), m))

// Part of 'T.Ident
| SynExpr.Typar (typar, m) ->
TcTyparExprThen cenv overallTy env tpenv typar m []

| SynExpr.IndexFromEnd (rightExpr, m) ->
errorR(Error(FSComp.SR.tcTraitInvocationShouldUseTick(), m))
let adjustedExpr = ParseHelpers.adjustHatPrefixToTyparLookup m rightExpr
Expand Down Expand Up @@ -7497,21 +7493,26 @@ and TcRecdExpr cenv overallTy env tpenv (inherits, withExprOpt, synRecdFields, m
| None -> expr
expr, tpenv

and CheckAnonRecdExprDuplicateFields (elems: Ident array) =
elems |> Array.iteri (fun i (uc1: Ident) ->
elems |> Array.iteri (fun j (uc2: Ident) ->
if j > i && uc1.idText = uc2.idText then
errorR(Error (FSComp.SR.tcAnonRecdDuplicateFieldId(uc1.idText), uc1.idRange))))

// Check '{| .... |}'
and TcAnonRecdExpr cenv (overallTy: TType) env tpenv (isStruct, optOrigSynExpr, unsortedFieldIdsAndSynExprsGiven, mWholeExpr) =

// Check for duplicate field IDs
unsortedFieldIdsAndSynExprsGiven
|> List.countBy (fun (fId, _, _) -> textOfLid fId.LongIdent)
|> List.iter (fun (label, count) ->
if count > 1 then error (Error (FSComp.SR.tcAnonRecdDuplicateFieldId(label), mWholeExpr)))

match optOrigSynExpr with
| None ->
TcNewAnonRecdExpr cenv overallTy env tpenv (isStruct, unsortedFieldIdsAndSynExprsGiven, mWholeExpr)

| Some orig ->
// Ideally we should also check for duplicate field IDs in the TcCopyAndUpdateAnonRecdExpr case, but currently the logic is too complex to garante a proper error reporting
// So here we error instead errorR to avoid cascading internal errors
unsortedFieldIdsAndSynExprsGiven
|> List.countBy (fun (fId, _, _) -> textOfLid fId.LongIdent)
|> List.iter (fun (label, count) ->
if count > 1 then error (Error (FSComp.SR.tcAnonRecdDuplicateFieldId(label), mWholeExpr)))

TcCopyAndUpdateAnonRecdExpr cenv overallTy env tpenv (isStruct, orig, unsortedFieldIdsAndSynExprsGiven, mWholeExpr)

and TcNewAnonRecdExpr cenv (overallTy: TType) env tpenv (isStruct, unsortedFieldIdsAndSynExprsGiven, mWholeExpr) =
Expand All @@ -7521,6 +7522,9 @@ and TcNewAnonRecdExpr cenv (overallTy: TType) env tpenv (isStruct, unsortedField
let unsortedFieldIds = unsortedFieldIdsAndSynExprsGiven |> List.map (fun (synLongIdent, _, _) -> synLongIdent.LongIdent[0]) |> List.toArray
let anonInfo, sortedFieldTys = UnifyAnonRecdTypeAndInferCharacteristics env.eContextInfo cenv env.DisplayEnv mWholeExpr overallTy isStruct unsortedFieldIds

if unsortedFieldIds.Length > 1 then
CheckAnonRecdExprDuplicateFields unsortedFieldIds

// Sort into canonical order
let sortedIndexedArgs =
unsortedFieldIdsAndSynExprsGiven
Expand Down
36 changes: 20 additions & 16 deletions src/Compiler/Checking/PatternMatchCompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -967,22 +967,26 @@ and erasePartials inps =
List.map erasePartialPatterns inps

let ReportUnusedTargets (clauses: MatchClause list) dtree =
let used = HashSet<_>(accTargetsOfDecisionTree dtree [], HashIdentity.Structural)
clauses |> List.iteri (fun i c ->
let m =
match c.BoundVals, c.GuardExpr with
| [], Some guard -> guard.Range
| [ bound ], None -> bound.Id.idRange
| [ _ ], Some guard -> guard.Range
| rest, None ->
match rest with
| [ head ] -> head.Id.idRange
| _ -> c.Pattern.Range
| _, Some guard -> guard.Range

let m = withStartEnd c.Range.Start m.End m

if not (used.Contains i) then warning (RuleNeverMatched m))
match dtree, clauses with
| TDSuccess _, [ _ ] -> ()
| _ ->
let used = HashSet<_>(accTargetsOfDecisionTree dtree [], HashIdentity.Structural)
clauses |> List.iteri (fun i c ->
if not (used.Contains i) then
let m =
match c.BoundVals, c.GuardExpr with
| [], Some guard -> guard.Range
| [ bound ], None -> bound.Id.idRange
| [ _ ], Some guard -> guard.Range
| rest, None ->
match rest with
| [ head ] -> head.Id.idRange
| _ -> c.Pattern.Range
| _, Some guard -> guard.Range

withStartEnd c.Range.Start m.End m
|> RuleNeverMatched
|> warning)

let rec isPatternDisjunctive inpPat =
match inpPat with
Expand Down
25 changes: 1 addition & 24 deletions src/Compiler/Driver/GraphChecking/DependencyResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ let collectGhostDependencies (fileIndex: FileIndex) (trie: TrieNode) (result: Fi
// We pick the lowest file index from the namespace to satisfy the type-checker for the open statement.
connectedFileIdx < fileIndex))

let mkGraph (compilingFSharpCore: bool) (filePairs: FilePairMap) (files: FileInProject array) : Graph<FileIndex> * TrieNode =
let mkGraph (filePairs: FilePairMap) (files: FileInProject array) : Graph<FileIndex> * TrieNode =
// We know that implementation files backed by signatures cannot be depended upon.
// Do not include them when building the Trie.
let trieInput =
Expand All @@ -189,23 +189,6 @@ let mkGraph (compilingFSharpCore: bool) (filePairs: FilePairMap) (files: FileInP
else
FileContentMapping.mkFileContent file)

// Files in FSharp.Core have an implicit dependency on `prim-types-prelude.fsi` - add it.
let fsharpCoreImplicitDependency =
if compilingFSharpCore then
let filename = "prim-types-prelude.fsi"

let implicitDepIdx =
files
|> Array.tryFindIndex (fun f -> System.IO.Path.GetFileName(f.FileName) = filename)

match implicitDepIdx with
| Some idx -> Some idx
| None ->
exn $"Expected to find file '{filename}' during compilation of FSharp.Core, but it was not found."
|> raise
else
None

let findDependencies (file: FileInProject) : FileIndex array =
if file.Idx = 0 then
// First file cannot have any dependencies.
Expand Down Expand Up @@ -234,17 +217,11 @@ let mkGraph (compilingFSharpCore: bool) (filePairs: FilePairMap) (files: FileInP
| None -> Array.empty
| Some sigIdx -> Array.singleton sigIdx

let fsharpCoreImplicitDependencyForThisFile =
match fsharpCoreImplicitDependency with
| Some depIdx when file.Idx > depIdx -> [| depIdx |]
| _ -> [||]

let allDependencies =
[|
yield! depsResult.FoundDependencies
yield! ghostDependencies
yield! signatureDependency
yield! fsharpCoreImplicitDependencyForThisFile
|]
|> Array.distinct

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ val processOpenPath: trie: TrieNode -> path: LongIdentifier -> state: FileConten
/// <summary>
/// Construct an approximate* dependency graph for files within a project, based on their ASTs.
/// </summary>
/// <param name="compilingFSharpCore">"Are we compiling FSharp.Core?" - used to add extra dependencies for FSharp.Core that are not otherwise detectable.</param>
/// <param name="filePairs">Maps the index of a signature file with the index of its implementation counterpart and vice versa.</param>
/// <param name="files">The files inside a project.</param>
/// <returns>A tuple consisting of a dictionary of FileIndex (alias for int) and a Trie</returns>
Expand All @@ -29,5 +28,4 @@ val processOpenPath: trie: TrieNode -> path: LongIdentifier -> state: FileConten
/// Hence this function cannot, as it stands, be used to help create a "reasonable" file ordering for an unordered set of files.
/// </para>
/// </remarks>
val mkGraph:
compilingFSharpCore: bool -> filePairs: FilePairMap -> files: FileInProject array -> Graph<FileIndex> * TrieNode
val mkGraph: filePairs: FilePairMap -> files: FileInProject array -> Graph<FileIndex> * TrieNode
6 changes: 2 additions & 4 deletions src/Compiler/Driver/ParseAndCheckInputs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1749,9 +1749,7 @@ let CheckMultipleInputsUsingGraphMode
})

let filePairs = FilePairMap(sourceFiles)

let graph, trie =
DependencyResolution.mkGraph tcConfig.compilingFSharpCore filePairs sourceFiles
let graph, trie = DependencyResolution.mkGraph filePairs sourceFiles

let nodeGraph =
let mkArtificialImplFile n = NodeToTypeCheck.ArtificialImplFile n
Expand Down Expand Up @@ -1898,7 +1896,7 @@ let CheckClosedInputSet (ctok, checkForErrors, tcConfig: TcConfig, tcImports, tc
// tcEnvAtEndOfLastFile is the environment required by fsi.exe when incrementally adding definitions
let results, tcState =
match tcConfig.typeCheckingConfig.Mode with
| TypeCheckingMode.Graph when (not tcConfig.isInteractive) ->
| TypeCheckingMode.Graph when (not tcConfig.isInteractive && not tcConfig.compilingFSharpCore) ->
CheckMultipleInputsUsingGraphMode(
ctok,
checkForErrors,
Expand Down
24 changes: 12 additions & 12 deletions src/Compiler/Facilities/DiagnosticsLogger.fs
Original file line number Diff line number Diff line change
Expand Up @@ -657,9 +657,8 @@ let CheckNoErrorsAndGetWarnings res =
| OkResult (warns, res2) -> Some(warns, res2)
| ErrorResult _ -> None

/// The bind in the monad. Stop on first error. Accumulate warnings and continue.
[<DebuggerHidden; DebuggerStepThrough>]
let (++) res f =
let bind f res =
match res with
| OkResult ([], res) -> (* tailcall *) f res
| OkResult (warns, res) ->
Expand All @@ -673,30 +672,30 @@ let (++) res f =
let rec IterateD f xs =
match xs with
| [] -> CompleteD
| h :: t -> f h ++ (fun () -> IterateD f t)
| h :: t -> f h |> bind (fun () -> IterateD f t)

[<DebuggerHidden; DebuggerStepThrough>]
let rec WhileD gd body =
if gd () then
body () ++ (fun () -> WhileD gd body)
body () |> bind (fun () -> WhileD gd body)
else
CompleteD

[<DebuggerHidden; DebuggerStepThrough>]
let rec MapD_loop f acc xs =
match xs with
| [] -> ResultD(List.rev acc)
| h :: t -> f h ++ (fun x -> MapD_loop f (x :: acc) t)
| h :: t -> f h |> bind (fun x -> MapD_loop f (x :: acc) t)

[<DebuggerHidden; DebuggerStepThrough>]
let MapD f xs = MapD_loop f [] xs

type TrackErrorsBuilder() =
member x.Bind(res, k) = res ++ k
member x.Bind(res, k) = bind k res
member x.Return res = ResultD res
member x.ReturnFrom res = res
member x.For(seq, k) = IterateD k seq
member x.Combine(expr1, expr2) = expr1 ++ expr2
member x.Combine(expr1, expr2) = bind expr2 expr1
member x.While(gd, k) = WhileD gd k
member x.Zero() = CompleteD
member x.Delay fn = fun () -> fn ()
Expand All @@ -717,7 +716,7 @@ let IterateIdxD f xs =
let rec loop xs i =
match xs with
| [] -> CompleteD
| h :: t -> f i h ++ (fun () -> loop t (i + 1))
| h :: t -> f i h |> bind (fun () -> loop t (i + 1))

loop xs 0

Expand All @@ -726,7 +725,7 @@ let IterateIdxD f xs =
let rec Iterate2D f xs ys =
match xs, ys with
| [], [] -> CompleteD
| h1 :: t1, h2 :: t2 -> f h1 h2 ++ (fun () -> Iterate2D f t1 t2)
| h1 :: t1, h2 :: t2 -> f h1 h2 |> bind (fun () -> Iterate2D f t1 t2)
| _ -> failwith "Iterate2D"

/// Keep the warnings, propagate the error to the exception continuation.
Expand All @@ -742,11 +741,12 @@ let TryD f g =

[<DebuggerHidden; DebuggerStepThrough>]
let rec RepeatWhileD nDeep body =
body nDeep ++ (fun x -> if x then RepeatWhileD (nDeep + 1) body else CompleteD)
body nDeep
|> bind (fun x -> if x then RepeatWhileD (nDeep + 1) body else CompleteD)

[<DebuggerHidden; DebuggerStepThrough>]
let inline AtLeastOneD f l =
MapD f l ++ (fun res -> ResultD(List.exists id res))
MapD f l |> bind (fun res -> ResultD(List.exists id res))

[<DebuggerHidden; DebuggerStepThrough>]
let inline AtLeastOne2D f xs ys =
Expand All @@ -755,7 +755,7 @@ let inline AtLeastOne2D f xs ys =
[<DebuggerHidden; DebuggerStepThrough>]
let inline MapReduceD mapper zero reducer l =
MapD mapper l
++ (fun res ->
|> bind (fun res ->
ResultD(
match res with
| [] -> zero
Expand Down
4 changes: 3 additions & 1 deletion src/Compiler/Facilities/DiagnosticsLogger.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ val ResultD: x: 'T -> OperationResult<'T>

val CheckNoErrorsAndGetWarnings: res: OperationResult<'T> -> (exn list * 'T) option

val (++): res: OperationResult<'T> -> f: ('T -> OperationResult<'b>) -> OperationResult<'b>
/// The bind in the monad. Stop on first error. Accumulate warnings and continue.
/// <remarks>Not meant for direct usage. Used in other inlined functions</remarks>
val bind: f: ('T -> OperationResult<'b>) -> res: OperationResult<'T> -> OperationResult<'b>

/// Stop on first error. Accumulate warnings and continue.
val IterateD: f: ('T -> OperationResult<unit>) -> xs: 'T list -> OperationResult<unit>
Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Service/FSharpParseFileResults.fs
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,6 @@ type FSharpParseFileResults(diagnostics: FSharpDiagnostic[], input: ParsedInput,

| SynExpr.Lambda (body = bodyExpr) -> yield! walkExpr true bodyExpr

| SynExpr.DotLambda (expr = bodyExpr) -> yield! walkExpr true bodyExpr

| SynExpr.Match (matchDebugPoint = spBind; expr = inpExpr; clauses = cl)
| SynExpr.MatchBang (matchDebugPoint = spBind; expr = inpExpr; clauses = cl) ->
yield! walkBindSeqPt spBind
Expand Down
2 changes: 0 additions & 2 deletions src/Compiler/Service/SemanticClassification.fs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ module TcResolutionsExtensions =

| Item.SetterArg _, _, m -> add m SemanticClassificationType.NamedArgument

| Item.SetterArg _, _, m -> add m SemanticClassificationType.Property

| Item.UnqualifiedType (tcref :: _), LegitTypeOccurence, m ->
if tcref.IsEnumTycon || tcref.IsILEnumTycon then
add m SemanticClassificationType.Enumeration
Expand Down
10 changes: 9 additions & 1 deletion src/Compiler/SyntaxTree/ParseHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,15 @@ let mkSynUnionCase attributes (access: SynAccess option) id kind mDecl (xmlDoc,

let mkAutoPropDefn mVal access ident typ mEquals (expr: SynExpr) accessors xmlDoc attribs flags rangeStart =
let mWith, (getSet, getSetOpt) = accessors
let memberRange = unionRanges rangeStart expr.Range |> unionRangeWithXmlDoc xmlDoc

let memberRange =
match getSetOpt with
| None -> unionRanges rangeStart expr.Range |> unionRangeWithXmlDoc xmlDoc
| Some (getSet: GetSetKeywords) ->
unionRanges rangeStart expr.Range
|> unionRangeWithXmlDoc xmlDoc
|> unionRanges getSet.Range

let flags, leadingKeyword = flags
let leadingKeyword = appendValToLeadingKeyword mVal leadingKeyword
let memberFlags: SynMemberFlags = flags SynMemberKind.Member
Expand Down
4 changes: 0 additions & 4 deletions src/Compiler/TypedTree/TypedTree.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3447,10 +3447,6 @@ type NonLocalEntityRef =
| ValueNone ->
errorR (InternalUndefinedItemRef (FSComp.SR.tastUndefinedItemRefModuleNamespace, nleref.DisplayName, nleref.AssemblyName, "<some module on this path>"))
raise (KeyNotFoundException())

/// Get the details of the module or namespace fragment for the entity referred to by this non-local reference.
member nleref.ModuleOrNamespaceType =
nleref.Deref.ModuleOrNamespaceType

[<DebuggerBrowsable(DebuggerBrowsableState.Never)>]
member x.DebugText = x.ToString()
Expand Down
3 changes: 0 additions & 3 deletions src/Compiler/TypedTree/TypedTree.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2317,9 +2317,6 @@ type NonLocalEntityRef =
/// Get the mangled name of the last item in the path of the nonlocal reference.
member LastItemMangledName: string

/// Get the details of the module or namespace fragment for the entity referred to by this non-local reference.
member ModuleOrNamespaceType: ModuleOrNamespaceType

/// Get the path into the CCU referenced by the nonlocal reference.
member Path: string[]

Expand Down
1 change: 0 additions & 1 deletion src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10065,7 +10065,6 @@ let (|CompiledInt32RangeForEachExpr|_|) g expr =
match expr with
| CompiledForEachExpr g (_, RangeInt32Step g (startExpr, step, finishExpr), elemVar, bodyExpr, ranges) ->
Some (startExpr, step, finishExpr, elemVar, bodyExpr, ranges)
| _ -> None
| _ -> None


Expand Down
Loading