Skip to content

Commit b47a70e

Browse files
authored
Merge branch 'main' into inline
2 parents 76c3bd2 + 26b3218 commit b47a70e

202 files changed

Lines changed: 7592 additions & 4317 deletions

File tree

Some content is hidden

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

.fantomasignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ scripts/
88
setup/
99
tests/
1010
vsintegration/*
11+
!vsintegration/src/FSharp.Editor
1112
!vsintegration/tests/FSharp.Editor.Tests
1213
artifacts/
1314

NuGet.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
<add key="dotnet7-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7-transport/nuget/v3/index.json" />
1515
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
1616
<add key="vssdk" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk/nuget/v3/index.json" />
17+
<add key="vssdk-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vssdk-archived/nuget/v3/index.json" />
1718
<add key="vs-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl/nuget/v3/index.json" />
19+
<add key="vs-impl-archived" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/vs-impl-archived/nuget/v3/index.json" />
1820
</packageSources>
1921
<disabledPackageSources>
2022
<clear />

src/Compiler/AbstractIL/ilwrite.fs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ type MetadataTable<'T> =
389389
| true, res -> res
390390
| _ -> tbl.AddSharedEntry x
391391

392+
member tbl.Contains x = tbl.dict.ContainsKey x
392393

393394
/// This is only used in one special place - see further below.
394395
member tbl.SetRowsOfTable t =
@@ -1070,6 +1071,17 @@ let GetMemberAccessFlags access =
10701071
| ILMemberAccess.Assembly -> 0x00000003
10711072

10721073
exception MethodDefNotFound
1074+
1075+
let private MethodDefIdxExists cenv (mref: ILMethodRef) =
1076+
let tref = mref.DeclaringTypeRef
1077+
if not (isTypeRefLocal tref) then
1078+
// Method referred to by method impl, event or property is not in a type defined in this module.
1079+
false
1080+
else
1081+
let tidx = GetIdxForTypeDef cenv (TdKey(tref.Enclosing, tref.Name))
1082+
let mdkey = MethodDefKey (cenv.ilg, tidx, mref.GenericArity, mref.Name, mref.ReturnType, mref.ArgTypes, mref.CallingConv.IsStatic)
1083+
cenv.methodDefIdxsByKey.Contains mdkey
1084+
10731085
let FindMethodDefIdx cenv mdkey =
10741086
try cenv.methodDefIdxsByKey.GetTableEntry mdkey
10751087
with :? KeyNotFoundException ->
@@ -1160,12 +1172,11 @@ let canGenEventDef cenv (ev: ILEventDef) =
11601172
if not cenv.referenceAssemblyOnly then
11611173
true
11621174
else
1163-
// If we have GetMethod or SetMethod set (i.e. not None), try and see if we have MethodDefs for them.
1175+
// If we have AddMethod or RemoveMethod set (i.e. not None), try and see if we have MethodDefs for them.
11641176
// NOTE: They can be not-None and missing MethodDefs if we skip generating them for reference assembly in the earlier pass.
1165-
// Only generate property if we have at least getter or setter, otherwise, we skip.
1177+
// Only generate event if we have at least add or remove, otherwise, we skip.
11661178
[| ev.AddMethod; ev.RemoveMethod |]
1167-
|> Array.map (TryGetMethodRefAsMethodDefIdx cenv)
1168-
|> Array.exists (function | Ok _ -> true | _ -> false)
1179+
|> Array.exists (MethodDefIdxExists cenv)
11691180

11701181
let canGenPropertyDef cenv (prop: ILPropertyDef) =
11711182
if not cenv.referenceAssemblyOnly then
@@ -1176,8 +1187,7 @@ let canGenPropertyDef cenv (prop: ILPropertyDef) =
11761187
// Only generate property if we have at least getter or setter, otherwise, we skip.
11771188
[| prop.GetMethod; prop.SetMethod |]
11781189
|> Array.choose id
1179-
|> Array.map (TryGetMethodRefAsMethodDefIdx cenv)
1180-
|> Array.exists (function | Ok _ -> true | _ -> false)
1190+
|> Array.exists (MethodDefIdxExists cenv)
11811191

11821192
let rec GetTypeDefAsRow cenv env _enc (tdef: ILTypeDef) =
11831193
let nselem, nelem = GetTypeNameAsElemPair cenv tdef.Name

src/Compiler/FSComp.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ keywordDescriptionRec,"Used to indicate that a function is recursive."
14451445
keywordDescriptionReturn,"Used to provide a value for the result of the containing computation expression."
14461446
keywordDescriptionReturnBang,"Used to provide a value for the result of the containing computation expression, where that value itself comes from the result another computation expression."
14471447
keywordDescriptionSelect,"Used in query expressions to specify what fields or columns to extract. Note that this is a contextual keyword, which means that it is not actually a reserved word and it only acts like a keyword in appropriate context."
1448+
keywordDescriptionSig,"Keyword reserved for ML-compatibility."
14481449
keywordDescriptionStatic,"Used to indicate a method or property that can be called without an instance of a type, or a value member that is shared among all instances of a type."
14491450
keywordDescriptionStruct,"Used to declare a structure type. Also used in generic parameter constraints."
14501451
keywordDescriptionThen,"Used in conditional expressions. Also used to perform side effects after object construction."
@@ -1681,4 +1682,5 @@ featureEscapeBracesInFormattableString,"Escapes curly braces before calling Form
16811682
3558,chkExplicitFieldsDeclarationsOnStaticClasses,"If a type uses both [<Sealed>] and [<AbstractClass>] attributes, it means it is static. Explicit field declarations are not allowed."
16821683
3559,typrelNeverRefinedAwayFromTop,"A type has been implicitly inferred as 'obj', which may be unintended. Consider adding explicit type annotations. You can disable this warning by using '#nowarn \"3559\"' or '--nowarn:3559'."
16831684
3560,tcCopyAndUpdateRecordChangesAllFields,"This copy-and-update record expression changes all fields of record type '%s'. Consider using the record construction syntax instead."
1684-
3561,chkAutoOpenAttributeInTypeAbbrev,"FSharp.Core.AutoOpenAttribute should not be aliased."
1685+
3561,chkAutoOpenAttributeInTypeAbbrev,"FSharp.Core.AutoOpenAttribute should not be aliased."
1686+
3562,parsUnexpectedEndOfFileElif,"Unexpected end of input in 'else if' or 'elif' branch of conditional expression. Expected 'elif <expr> then <expr>' or 'else if <expr> then <expr>'."

src/Compiler/Service/ItemKey.fs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ open FSharp.Compiler.Text
1515
open FSharp.Compiler.Text.Range
1616
open FSharp.Compiler.TypedTree
1717
open FSharp.Compiler.TypedTreeBasics
18+
open FSharp.Compiler.Syntax.PrettyNaming
1819

1920
#nowarn "9"
2021
#nowarn "51"
@@ -301,6 +302,19 @@ and [<Sealed>] ItemKeyStoreBuilder() =
301302
| ParentNone -> writeChar '%'
302303
| Parent eref -> writeEntityRef eref
303304

305+
let writeActivePatternCase (apInfo: ActivePatternInfo) index =
306+
writeString ItemKeyTags.itemActivePattern
307+
308+
match apInfo.ActiveTagsWithRanges with
309+
| (_, m) :: _ -> m.FileName |> Path.GetFileNameWithoutExtension |> writeString
310+
| _ -> ()
311+
312+
for tag in apInfo.ActiveTags do
313+
writeChar '|'
314+
writeString tag
315+
316+
writeInt32 index
317+
304318
member _.Write(m: range, item: Item) =
305319
writeRange m
306320

@@ -325,13 +339,9 @@ and [<Sealed>] ItemKeyStoreBuilder() =
325339
writeEntityRef info.TyconRef
326340
writeString info.LogicalName
327341

328-
| Item.ActivePatternResult (info, _, _, _) ->
329-
writeString ItemKeyTags.itemActivePattern
330-
info.ActiveTags |> List.iter writeString
342+
| Item.ActivePatternResult (info, _, index, _) -> writeActivePatternCase info index
331343

332-
| Item.ActivePatternCase elemRef ->
333-
writeString ItemKeyTags.itemActivePattern
334-
elemRef.ActivePatternInfo.ActiveTags |> List.iter writeString
344+
| Item.ActivePatternCase elemRef -> writeActivePatternCase elemRef.ActivePatternInfo elemRef.CaseIndex
335345

336346
| Item.ExnCase tcref ->
337347
writeString ItemKeyTags.itemExnCase

src/Compiler/Service/ServiceCompilerDiagnostics.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ open FSharp.Compiler.DiagnosticResolutionHints
88
type FSharpDiagnosticKind =
99
| AddIndexerDot
1010
| ReplaceWithSuggestion of suggestion: string
11+
| RemoveIndexerDot
1112

1213
[<RequireQualifiedAccess>]
1314
module CompilerDiagnostics =
@@ -16,6 +17,7 @@ module CompilerDiagnostics =
1617
match diagnosticKind with
1718
| FSharpDiagnosticKind.AddIndexerDot -> FSComp.SR.addIndexerDot ()
1819
| FSharpDiagnosticKind.ReplaceWithSuggestion s -> FSComp.SR.replaceWithSuggestion (s)
20+
| FSharpDiagnosticKind.RemoveIndexerDot -> FSComp.SR.tcIndexNotationDeprecated () |> snd
1921

2022
let GetSuggestedNames (suggestionsF: FSharp.Compiler.DiagnosticsLogger.Suggestions) (unresolvedIdentifier: string) =
2123
let buffer = SuggestionBuffer(unresolvedIdentifier)

src/Compiler/Service/ServiceCompilerDiagnostics.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace FSharp.Compiler.Diagnostics
77
type FSharpDiagnosticKind =
88
| AddIndexerDot
99
| ReplaceWithSuggestion of suggestion: string
10+
| RemoveIndexerDot
1011

1112
/// Exposes compiler diagnostic error messages.
1213
module CompilerDiagnostics =

src/Compiler/SyntaxTree/PrettyNaming.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ let keywordsWithDescription: (string * string) list =
224224
"rec", FSComp.SR.keywordDescriptionRec ()
225225
"return", FSComp.SR.keywordDescriptionReturn ()
226226
"return!", FSComp.SR.keywordDescriptionReturnBang ()
227+
"sig", FSComp.SR.keywordDescriptionSig ()
227228
"static", FSComp.SR.keywordDescriptionStatic ()
228229
"struct", FSComp.SR.keywordDescriptionStruct ()
229230
"then", FSComp.SR.keywordDescriptionThen ()

src/Compiler/SyntaxTree/SyntaxTreeOps.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ let rec synExprContainsError inpExpr =
813813
| SynExpr.ComputationExpr (_, e, _)
814814
| SynExpr.ArrayOrListComputed (_, e, _)
815815
| SynExpr.Typed (e, _, _)
816-
| SynExpr.FromParseError (e, _)
817816
| SynExpr.Do (e, _)
818817
| SynExpr.Assert (e, _)
819818
| SynExpr.DotGet (e, _, _, _)

src/Compiler/pars.fsy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4207,8 +4207,9 @@ ifExprElifs:
42074207
else
42084208
None, Some ($3 $2 mElif true) }
42094209

4210-
| ELIF declExpr recover
4211-
{ None, Some (exprFromParseError $2) }
4210+
| ELIF declExpr recover
4211+
{ if not $3 then reportParseErrorAt (rhs parseState 1) (FSComp.SR.parsUnexpectedEndOfFileElif())
4212+
None, Some (exprFromParseError $2) }
42124213

42134214
tupleExpr:
42144215
| tupleExpr COMMA declExpr

0 commit comments

Comments
 (0)