From 861d0b03dc78848145038df940999f7b4914cfb0 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 27 Sep 2019 23:40:44 +0300 Subject: [PATCH 01/68] Remove unused opens --- .../ProjectCracker.fs | 3 -- .../ProjectCrackerTool.fs | 1 - src/absil/bytes.fs | 4 -- src/absil/il.fs | 1 - src/absil/ilbinary.fs | 3 -- src/absil/ildiag.fs | 1 - src/absil/ilmorph.fs | 3 -- src/absil/ilprint.fs | 4 -- src/absil/ilread.fs | 3 -- src/absil/ilreflect.fs | 1 - src/absil/ilsupp.fs | 4 -- src/absil/ilwrite.fs | 4 -- src/absil/ilwritepdb.fs | 2 - src/absil/ilx.fs | 3 -- src/absil/zset.fs | 2 - src/fsharp/CompileOps.fs | 1 - src/fsharp/CompilerGlobalState.fs | 1 - src/fsharp/DotNetFrameworkDependencies.fs | 1 - src/fsharp/ExtensionTyping.fs | 1 - src/fsharp/IlxGen.fs | 2 - src/fsharp/InfoReader.fs | 1 - src/fsharp/InternalCollections.fs | 1 - src/fsharp/LexFilter.fs | 2 - src/fsharp/LowerCallsAndSeqs.fs | 1 - src/fsharp/QuotationPickler.fs | 1 - src/fsharp/TastPickle.fs | 1 - src/fsharp/TypeRelations.fs | 1 - src/fsharp/UnicodeLexing.fs | 2 - src/fsharp/XmlAdapters.fs | 4 -- src/fsharp/ast.fs | 2 - src/fsharp/fsc.fs | 4 -- src/fsharp/fsi/fsi.fs | 10 ---- src/fsharp/import.fs | 1 - src/fsharp/layout.fs | 1 - src/fsharp/lexhelp.fs | 4 -- src/fsharp/lib.fs | 1 - src/fsharp/service/IncrementalBuild.fs | 2 - src/fsharp/service/ServiceAnalysis.fs | 1 - src/fsharp/service/ServiceAssemblyContent.fs | 2 - src/fsharp/service/ServiceDeclarationLists.fs | 1 - src/fsharp/service/ServiceUntypedParse.fs | 2 - src/fsharp/service/ServiceXmlDocParser.fs | 1 - src/fsharp/service/service.fs | 1 - src/fsharp/sr.fs | 8 ---- src/fsharp/symbols/SymbolHelpers.fs | 1 - src/fsharp/tainted.fs | 3 -- src/ilx/EraseClosures.fs | 5 -- src/ilx/EraseUnions.fs | 2 - src/ilx/ilxsettings.fs | 2 - src/utils/CompilerLocationUtils.fs | 1 - src/utils/EditDistance.fs | 1 - src/utils/HashMultiMap.fs | 1 - src/utils/TaggedCollections.fs | 4 -- src/utils/prim-parsing.fs | 2 - src/utils/sformat.fs | 6 --- tests/service/AssemblyReaderShim.fs | 1 - tests/service/CSharpProjectAnalysis.fs | 6 --- tests/service/Common.fs | 1 - tests/service/EditorTests.fs | 1 - tests/service/ExprTests.fs | 4 -- tests/service/FileSystemTests.fs | 2 - tests/service/InteractiveCheckerTests.fs | 1 - tests/service/MultiProjectAnalysisTests.fs | 15 ------ tests/service/PerfTests.fs | 4 -- tests/service/ProjectAnalysisTests.fs | 46 ------------------- tests/service/ProjectOptionsTests.fs | 1 - tests/service/TokenizerTests.fs | 5 -- 67 files changed, 215 deletions(-) diff --git a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs index d5be2c7565f..3a096cb5660 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs @@ -2,13 +2,10 @@ #if !NETSTANDARD open System.Runtime.Serialization.Json -open System.Runtime -open System.Diagnostics #endif open System.Text open System.IO open System -open System.Xml module Utils = diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs index 7cf970f7a7f..93a74cbb0e8 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs @@ -8,7 +8,6 @@ open Microsoft.Build.Utilities module internal ProjectCrackerTool = open System.Collections.Generic - open Microsoft.Build.Evaluation let runningOnMono = #if NETCOREAPP2_0 diff --git a/src/absil/bytes.fs b/src/absil/bytes.fs index a272b99a454..d488f7acc89 100644 --- a/src/absil/bytes.fs +++ b/src/absil/bytes.fs @@ -3,11 +3,7 @@ /// Byte arrays namespace FSharp.Compiler.AbstractIL.Internal -open System.IO -open Internal.Utilities -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal module internal Bytes = let b0 n = (n &&& 0xFF) diff --git a/src/absil/il.fs b/src/absil/il.fs index 51b75e55fbb..e30160d2fd6 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -12,7 +12,6 @@ open System.IO open System.Collections open System.Collections.Generic open System.Collections.Concurrent -open System.Runtime.CompilerServices open System.Reflection open System.Text open System.Threading diff --git a/src/absil/ilbinary.fs b/src/absil/ilbinary.fs index 2b22b4cbabb..eea2f06bfda 100644 --- a/src/absil/ilbinary.fs +++ b/src/absil/ilbinary.fs @@ -2,10 +2,7 @@ module internal FSharp.Compiler.AbstractIL.Internal.BinaryConstants -open Internal.Utilities -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library [] diff --git a/src/absil/ildiag.fs b/src/absil/ildiag.fs index de7411fbf9b..1cd20ad8750 100644 --- a/src/absil/ildiag.fs +++ b/src/absil/ildiag.fs @@ -4,7 +4,6 @@ module internal FSharp.Compiler.AbstractIL.Diagnostics -open Internal.Utilities let diagnosticsLog = ref (Some stdout) diff --git a/src/absil/ilmorph.fs b/src/absil/ilmorph.fs index ffd86aa504b..fd59b34e93c 100644 --- a/src/absil/ilmorph.fs +++ b/src/absil/ilmorph.fs @@ -3,11 +3,8 @@ module internal FSharp.Compiler.AbstractIL.Morphs open System.Collections.Generic -open Internal.Utilities open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library -open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.IL let mutable morphCustomAttributeData = false diff --git a/src/absil/ilprint.fs b/src/absil/ilprint.fs index e2ed4e9302e..7f408d48cbc 100644 --- a/src/absil/ilprint.fs +++ b/src/absil/ilprint.fs @@ -2,16 +2,12 @@ module internal FSharp.Compiler.AbstractIL.ILAsciiWriter -open Internal.Utilities -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library -open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.Extensions.ILX.Types open FSharp.Compiler.AbstractIL.Internal.AsciiConstants open FSharp.Compiler.AbstractIL.IL -open System.Text open System.IO open System.Reflection diff --git a/src/absil/ilread.fs b/src/absil/ilread.fs index 38c1c5ff817..cc5c865515a 100644 --- a/src/absil/ilread.fs +++ b/src/absil/ilread.fs @@ -18,7 +18,6 @@ open System.Runtime.InteropServices open System.Text open Internal.Utilities open Internal.Utilities.Collections -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Support open FSharp.Compiler.AbstractIL.Diagnostics @@ -27,7 +26,6 @@ open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Range -open Microsoft.FSharp.NativeInterop open System.Reflection let checking = false @@ -4128,7 +4126,6 @@ let OpenILModuleReader fileName opts = [] module Shim = - open FSharp.Compiler.Lib type IAssemblyReader = abstract GetILModuleReader: filename: string * readerOptions: ILReaderOptions -> ILModuleReader diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index cf43af269e6..336215f69b2 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -19,7 +19,6 @@ open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.AbstractIL.ILAsciiWriter open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Range open FSharp.Core.Printf diff --git a/src/absil/ilsupp.fs b/src/absil/ilsupp.fs index fb8a98b3494..308120152e5 100644 --- a/src/absil/ilsupp.fs +++ b/src/absil/ilsupp.fs @@ -2,11 +2,8 @@ module internal FSharp.Compiler.AbstractIL.Internal.Support -open Internal.Utilities open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Internal -open FSharp.Compiler.AbstractIL.Internal.Bytes -open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Internal.NativeRes #if FX_NO_CORHOST_SIGNER @@ -15,7 +12,6 @@ open FSharp.Compiler.AbstractIL.Internal.StrongNameSign open System open System.IO -open System.Text open System.Reflection #if !FX_NO_SYMBOLSTORE diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index dbd8a288755..dc5a944ac0d 100644 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -6,17 +6,13 @@ open System.Collections.Generic open System.IO open Internal.Utilities -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.ILAsciiWriter open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Diagnostics -open FSharp.Compiler.AbstractIL.Extensions.ILX.Types open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.BinaryConstants open FSharp.Compiler.AbstractIL.Internal.Support open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.ILPdbWriter -open FSharp.Compiler.DiagnosticMessage open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Range #if FX_NO_CORHOST_SIGNER diff --git a/src/absil/ilwritepdb.fs b/src/absil/ilwritepdb.fs index 90d53444e78..682b20a6888 100644 --- a/src/absil/ilwritepdb.fs +++ b/src/absil/ilwritepdb.fs @@ -10,11 +10,9 @@ open System.IO.Compression open System.Reflection open System.Reflection.Metadata open System.Reflection.Metadata.Ecma335 -open System.Reflection.PortableExecutable open System.Text open Internal.Utilities open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.Internal.Support open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.ErrorLogger diff --git a/src/absil/ilx.fs b/src/absil/ilx.fs index 56d264a6dcd..2b364186c98 100644 --- a/src/absil/ilx.fs +++ b/src/absil/ilx.fs @@ -3,9 +3,6 @@ /// Defines an extension of the IL algebra module internal FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open Internal.Utilities -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library diff --git a/src/absil/zset.fs b/src/absil/zset.fs index 5d6588a5986..aee52eb68e3 100644 --- a/src/absil/zset.fs +++ b/src/absil/zset.fs @@ -3,9 +3,7 @@ namespace FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library -open Internal.Utilities open Internal.Utilities.Collections.Tagged open System.Collections.Generic diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 239015820aa..425bcaf374b 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -4941,7 +4941,6 @@ type CodeContext = module private ScriptPreprocessClosure = - open Internal.Utilities.Text.Lexing /// Represents an input to the closure finding process type ClosureSource = ClosureSource of filename: string * referenceRange: range * sourceText: ISourceText * parseRequired: bool diff --git a/src/fsharp/CompilerGlobalState.fs b/src/fsharp/CompilerGlobalState.fs index 1e857e7cade..a54fc0426ae 100644 --- a/src/fsharp/CompilerGlobalState.fs +++ b/src/fsharp/CompilerGlobalState.fs @@ -5,7 +5,6 @@ namespace FSharp.Compiler open System.Collections.Generic -open FSharp.Compiler.AbstractIL open FSharp.Compiler.Range open FSharp.Compiler.PrettyNaming diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index 2e96dcd3674..34d1c7d8992 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -6,7 +6,6 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies open System open System.Collections.Generic - open System.Diagnostics open System.IO open System.Reflection diff --git a/src/fsharp/ExtensionTyping.fs b/src/fsharp/ExtensionTyping.fs index c075e0dbe96..3e1692e78b1 100755 --- a/src/fsharp/ExtensionTyping.fs +++ b/src/fsharp/ExtensionTyping.fs @@ -15,7 +15,6 @@ module internal ExtensionTyping = open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Range open FSharp.Compiler.AbstractIL.IL - open FSharp.Compiler.AbstractIL.Diagnostics // dprintfn open FSharp.Compiler.AbstractIL.Internal.Library // frontAndBack type TypeProviderDesignation = TypeProviderDesignation of string diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 62300df6766..3adebb1872e 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -1832,7 +1832,6 @@ module CG = let SetStack (cgbuf: CodeGenBuffer) s = cgbuf.SetStack s let GenerateMark (cgbuf: CodeGenBuffer) s = cgbuf.Mark s -open CG //-------------------------------------------------------------------------- @@ -7622,7 +7621,6 @@ let GenerateCode (cenv, anonTypeTable, eenv, TypedAssemblyAfterOptimization file //------------------------------------------------------------------------- open System -open System.Reflection /// The lookup* functions are the conversions available from ilreflect. type ExecutionContext = diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index 7e9dffdd52b..d23fe4b4a8d 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -6,7 +6,6 @@ module internal FSharp.Compiler.InfoReader open System.Collections.Generic -open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler open FSharp.Compiler.AccessibilityLogic diff --git a/src/fsharp/InternalCollections.fs b/src/fsharp/InternalCollections.fs index eda256e715c..34076bf5fd6 100755 --- a/src/fsharp/InternalCollections.fs +++ b/src/fsharp/InternalCollections.fs @@ -2,7 +2,6 @@ namespace Internal.Utilities.Collections open System -open System.Collections.Generic [] type internal ValueStrength<'T when 'T : not struct> = diff --git a/src/fsharp/LexFilter.fs b/src/fsharp/LexFilter.fs index e37b0c35b1b..468ac0b3aa2 100755 --- a/src/fsharp/LexFilter.fs +++ b/src/fsharp/LexFilter.fs @@ -6,8 +6,6 @@ module internal FSharp.Compiler.LexFilter open Internal.Utilities.Text.Lexing open FSharp.Compiler -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.Ast diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs index 6bc583faae1..ccf4d0c1f25 100644 --- a/src/fsharp/LowerCallsAndSeqs.fs +++ b/src/fsharp/LowerCallsAndSeqs.fs @@ -14,7 +14,6 @@ open FSharp.Compiler.ErrorLogger open FSharp.Compiler.Tast open FSharp.Compiler.Tastops open FSharp.Compiler.Lib -open FSharp.Compiler.TcGlobals open FSharp.Compiler.InfoReader open FSharp.Compiler.MethodCalls diff --git a/src/fsharp/QuotationPickler.fs b/src/fsharp/QuotationPickler.fs index 90a9e299947..82273b01ab7 100644 --- a/src/fsharp/QuotationPickler.fs +++ b/src/fsharp/QuotationPickler.fs @@ -5,7 +5,6 @@ module internal FSharp.Compiler.QuotationPickler open System.Text open Internal.Utilities.Collections open FSharp.Compiler.AbstractIL.Internal -open FSharp.Compiler open FSharp.Compiler.Lib let mkRLinear mk (vs, body) = List.foldBack (fun v acc -> mk (v, acc)) vs body diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index da6906cf33c..deab45911f9 100644 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -6,7 +6,6 @@ open System.Collections.Generic open System.Text open Internal.Utilities open FSharp.Compiler -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library diff --git a/src/fsharp/TypeRelations.fs b/src/fsharp/TypeRelations.fs index 29c95cc55a9..dd32a6ee001 100755 --- a/src/fsharp/TypeRelations.fs +++ b/src/fsharp/TypeRelations.fs @@ -11,7 +11,6 @@ open FSharp.Compiler.Tast open FSharp.Compiler.Tastops open FSharp.Compiler.TcGlobals open FSharp.Compiler.Infos -open FSharp.Compiler.PrettyNaming /// Implements a :> b without coercion based on finalized (no type variable) types // Note: This relation is approximate and not part of the language specification. diff --git a/src/fsharp/UnicodeLexing.fs b/src/fsharp/UnicodeLexing.fs index d34092940e2..c776a1f1f76 100644 --- a/src/fsharp/UnicodeLexing.fs +++ b/src/fsharp/UnicodeLexing.fs @@ -7,8 +7,6 @@ module internal FSharp.Compiler.UnicodeLexing // open FSharp.Compiler.AbstractIL.Internal.Library -open FSharp.Compiler.Features -open Internal.Utilities open System.IO open Internal.Utilities.Text.Lexing diff --git a/src/fsharp/XmlAdapters.fs b/src/fsharp/XmlAdapters.fs index 4f48955945a..2e04733fc18 100644 --- a/src/fsharp/XmlAdapters.fs +++ b/src/fsharp/XmlAdapters.fs @@ -1,13 +1,9 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. namespace Microsoft.FSharp.Core -open System.Reflection //Replacement for: System.Security.SecurityElement.Escape(line) All platforms module internal XmlAdapters = - open System.Text - open Microsoft.FSharp.Collections - let s_escapeChars = [| '<'; '>'; '\"'; '\''; '&' |] let getEscapeSequence c = diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index 59e93205ce1..d8406e1a85b 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -2,12 +2,10 @@ module public FSharp.Compiler.Ast -open System.Collections.Generic open Internal.Utilities.Text.Lexing open Internal.Utilities.Text.Parsing open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler open FSharp.Compiler.UnicodeLexing diff --git a/src/fsharp/fsc.fs b/src/fsharp/fsc.fs index dc5777cdc39..bb46f75e1db 100644 --- a/src/fsharp/fsc.fs +++ b/src/fsharp/fsc.fs @@ -13,13 +13,11 @@ module internal FSharp.Compiler.Driver open System -open System.Collections.Concurrent open System.Collections.Generic open System.Diagnostics open System.Globalization open System.IO open System.Reflection -open System.Runtime.CompilerServices open System.Text open System.Threading @@ -37,7 +35,6 @@ open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.IlxGen open FSharp.Compiler.AccessibilityLogic -open FSharp.Compiler.AttributeChecking open FSharp.Compiler.Ast open FSharp.Compiler.CompileOps open FSharp.Compiler.CompileOptions @@ -1105,7 +1102,6 @@ module MainModuleBuilder = /// Optional static linking of all DLLs that depend on the F# Library, plus other specified DLLs module StaticLinker = - open FSharp.Compiler.AbstractIL // Handles TypeForwarding for the generated IL model type TypeForwarding (tcImports: TcImports) = diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 99bffe0b73c..de1f7335987 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -13,20 +13,16 @@ open System open System.Collections.Generic open System.Diagnostics open System.Globalization -open System.Runtime.InteropServices open System.IO open System.Text open System.Threading open System.Reflection -open System.Runtime.CompilerServices open FSharp.Compiler open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILBinaryReader -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library -open FSharp.Compiler.AbstractIL.Extensions.ILX open FSharp.Compiler.AbstractIL.ILRuntimeWriter open FSharp.Compiler.Lib open FSharp.Compiler.AccessibilityLogic @@ -34,16 +30,11 @@ open FSharp.Compiler.Ast open FSharp.Compiler.CompileOptions open FSharp.Compiler.CompileOps open FSharp.Compiler.ErrorLogger -open FSharp.Compiler.Features -open FSharp.Compiler.Infos open FSharp.Compiler.InfoReader open FSharp.Compiler.NameResolution open FSharp.Compiler.IlxGen open FSharp.Compiler.Lexhelp open FSharp.Compiler.Layout -open FSharp.Compiler.Lib -open FSharp.Compiler.Optimizer -open FSharp.Compiler.PostTypeCheckSemanticChecks open FSharp.Compiler.Range open FSharp.Compiler.TypeChecker open FSharp.Compiler.Tast @@ -54,7 +45,6 @@ open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.ReferenceResolver open Internal.Utilities -open Internal.Utilities.Collections open Internal.Utilities.StructuredFormat //---------------------------------------------------------------------------- diff --git a/src/fsharp/import.fs b/src/fsharp/import.fs index 8fdd28f3b54..29943461bd3 100644 --- a/src/fsharp/import.fs +++ b/src/fsharp/import.fs @@ -3,7 +3,6 @@ /// Functions to import .NET binary metadata as TAST objects module internal FSharp.Compiler.Import -open System.Reflection open System.Collections.Concurrent open System.Collections.Generic diff --git a/src/fsharp/layout.fs b/src/fsharp/layout.fs index d63a8f8f023..fc6a52d763e 100644 --- a/src/fsharp/layout.fs +++ b/src/fsharp/layout.fs @@ -3,7 +3,6 @@ module FSharp.Compiler.Layout open System -open System.Collections.Generic open System.IO open Internal.Utilities.StructuredFormat open Microsoft.FSharp.Core.Printf diff --git a/src/fsharp/lexhelp.fs b/src/fsharp/lexhelp.fs index 6a9a6430cbd..b25627e9a45 100644 --- a/src/fsharp/lexhelp.fs +++ b/src/fsharp/lexhelp.fs @@ -6,19 +6,15 @@ open System open System.Text open Internal.Utilities -open Internal.Utilities.Collections -open Internal.Utilities.Text open Internal.Utilities.Text.Lexing open FSharp.Compiler -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.Lib open FSharp.Compiler.Ast open FSharp.Compiler.PrettyNaming open FSharp.Compiler.ErrorLogger -open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.Range open FSharp.Compiler.Parser diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index 6c4599f8a1c..ceb8062115f 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -5,7 +5,6 @@ module internal FSharp.Compiler.Lib open System.IO open System.Collections.Generic open Internal.Utilities -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index 96e81e32147..406e16db7a9 100755 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -4,7 +4,6 @@ namespace FSharp.Compiler open System -open System.Collections.Concurrent open System.Collections.Generic open System.IO open System.Threading @@ -18,7 +17,6 @@ open FSharp.Compiler.AbstractIL.ILBinaryReader open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.CompileOps open FSharp.Compiler.CompileOptions -open FSharp.Compiler.Ast open FSharp.Compiler.ErrorLogger open FSharp.Compiler.TcGlobals open FSharp.Compiler.TypeChecker diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index e4f942b657a..70cf19fb4ac 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -3,7 +3,6 @@ namespace FSharp.Compiler.SourceCodeServices open FSharp.Compiler -open FSharp.Compiler.Ast open FSharp.Compiler.Range open FSharp.Compiler.PrettyNaming open System.Collections.Generic diff --git a/src/fsharp/service/ServiceAssemblyContent.fs b/src/fsharp/service/ServiceAssemblyContent.fs index 8ceb381225b..1a375fdf337 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fs +++ b/src/fsharp/service/ServiceAssemblyContent.fs @@ -491,8 +491,6 @@ type OpenStatementInsertionPoint = | Nearest module ParsedInput = - open FSharp.Compiler - open FSharp.Compiler.Ast /// An recursive pattern that collect all sequential expressions to avoid StackOverflowException let rec (|Sequentials|_|) = function diff --git a/src/fsharp/service/ServiceDeclarationLists.fs b/src/fsharp/service/ServiceDeclarationLists.fs index c4bf83bf087..ef9c0b40987 100644 --- a/src/fsharp/service/ServiceDeclarationLists.fs +++ b/src/fsharp/service/ServiceDeclarationLists.fs @@ -8,7 +8,6 @@ namespace FSharp.Compiler.SourceCodeServices open FSharp.Compiler -open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Diagnostics open FSharp.Compiler.AccessibilityLogic diff --git a/src/fsharp/service/ServiceUntypedParse.fs b/src/fsharp/service/ServiceUntypedParse.fs index 84c8947d13d..04c79ab1362 100755 --- a/src/fsharp/service/ServiceUntypedParse.fs +++ b/src/fsharp/service/ServiceUntypedParse.fs @@ -17,8 +17,6 @@ open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler open FSharp.Compiler.Range open FSharp.Compiler.Ast -open FSharp.Compiler.ErrorLogger -open FSharp.Compiler.CompileOps open FSharp.Compiler.Lib open FSharp.Compiler.PrettyNaming diff --git a/src/fsharp/service/ServiceXmlDocParser.fs b/src/fsharp/service/ServiceXmlDocParser.fs index cac3a2743dd..5b71775adce 100644 --- a/src/fsharp/service/ServiceXmlDocParser.fs +++ b/src/fsharp/service/ServiceXmlDocParser.fs @@ -2,7 +2,6 @@ namespace FSharp.Compiler.SourceCodeServices -open FSharp.Compiler open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.Text diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 7eac7390c29..6250c87a929 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -19,7 +19,6 @@ open FSharp.Compiler.CompileOps open FSharp.Compiler.CompileOptions open FSharp.Compiler.Driver open FSharp.Compiler.ErrorLogger -open FSharp.Compiler.Features open FSharp.Compiler.Lib open FSharp.Compiler.Range open FSharp.Compiler.TcGlobals diff --git a/src/fsharp/sr.fs b/src/fsharp/sr.fs index ee64fcdb19e..ae81bb6abcf 100644 --- a/src/fsharp/sr.fs +++ b/src/fsharp/sr.fs @@ -2,13 +2,8 @@ namespace FSharp.Compiler open Microsoft.FSharp.Core - open Microsoft.FSharp.Core.Operators open Microsoft.FSharp.Collections open Microsoft.FSharp.Reflection - open System.Globalization - open System.IO - open System.Text - open System.Reflection module internal SR = let private resources = lazy (new System.Resources.ResourceManager("fsstrings", System.Reflection.Assembly.GetExecutingAssembly())) @@ -24,9 +19,6 @@ namespace FSharp.Compiler module internal DiagnosticMessage = open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators - open Microsoft.FSharp.Reflection - open System.Reflection - open Internal.Utilities.StructuredFormat let mkFunctionValue (tys: System.Type[]) (impl:obj->obj) = FSharpValue.MakeFunction(FSharpType.MakeFunctionType(tys.[0],tys.[1]), impl) diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index b1c46d9bd72..e818d441817 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -8,7 +8,6 @@ namespace FSharp.Compiler.SourceCodeServices open System -open System.Collections.Generic open System.IO open Microsoft.FSharp.Core.Printf diff --git a/src/fsharp/tainted.fs b/src/fsharp/tainted.fs index ebdc96c746a..15d2378b3fb 100644 --- a/src/fsharp/tainted.fs +++ b/src/fsharp/tainted.fs @@ -9,9 +9,6 @@ open FSharp.Compiler.Range open Microsoft.FSharp.Core.CompilerServices open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library -open System.Reflection -open System.Collections.Generic -open ErrorLogger type internal TypeProviderError ( diff --git a/src/ilx/EraseClosures.fs b/src/ilx/EraseClosures.fs index ca0dbfcdf8e..abc5e4bc977 100644 --- a/src/ilx/EraseClosures.fs +++ b/src/ilx/EraseClosures.fs @@ -2,18 +2,13 @@ module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseClosures -open Internal.Utilities -open FSharp.Compiler.AbstractIL -open FSharp.Compiler.AbstractIL.Internal open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.Extensions.ILX open FSharp.Compiler.AbstractIL.Extensions.ILX.Types -open FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings open FSharp.Compiler.AbstractIL.Morphs open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.PrettyNaming -open System.Reflection // -------------------------------------------------------------------- // Erase closures and function types diff --git a/src/ilx/EraseUnions.fs b/src/ilx/EraseUnions.fs index 1d0175676c8..c24a30a6105 100644 --- a/src/ilx/EraseUnions.fs +++ b/src/ilx/EraseUnions.fs @@ -9,10 +9,8 @@ module internal FSharp.Compiler.AbstractIL.Extensions.ILX.EraseUnions open System.Collections.Generic -open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal.Library -open FSharp.Compiler.AbstractIL.Extensions.ILX open FSharp.Compiler.AbstractIL.Extensions.ILX.Types open System.Reflection diff --git a/src/ilx/ilxsettings.fs b/src/ilx/ilxsettings.fs index 868a29d94e1..64ea572e02f 100644 --- a/src/ilx/ilxsettings.fs +++ b/src/ilx/ilxsettings.fs @@ -2,11 +2,9 @@ module internal FSharp.Compiler.AbstractIL.Extensions.ILX.IlxSettings -open Internal.Utilities open FSharp.Compiler.AbstractIL open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.Internal -open FSharp.Compiler.AbstractIL.Extensions.ILX type IlxCallImplementation = | VirtEntriesVirtCode diff --git a/src/utils/CompilerLocationUtils.fs b/src/utils/CompilerLocationUtils.fs index 95aa5c5a31e..fe6728586b6 100644 --- a/src/utils/CompilerLocationUtils.fs +++ b/src/utils/CompilerLocationUtils.fs @@ -3,7 +3,6 @@ namespace Internal.Utilities open System open System.IO -open System.Reflection open Microsoft.Win32 open System.Runtime.InteropServices diff --git a/src/utils/EditDistance.fs b/src/utils/EditDistance.fs index 503662400ff..bd66352d44d 100644 --- a/src/utils/EditDistance.fs +++ b/src/utils/EditDistance.fs @@ -4,7 +4,6 @@ module internal Internal.Utilities.EditDistance open System -open System.Collections.Generic /// Given an offset and a radius from that offset, does mChar exist in that part of str? let inline existsInWin (mChar: char) (str: string) (offset: int) (rad: int) = diff --git a/src/utils/HashMultiMap.fs b/src/utils/HashMultiMap.fs index 7f571c232d0..a76b3ccc253 100644 --- a/src/utils/HashMultiMap.fs +++ b/src/utils/HashMultiMap.fs @@ -2,7 +2,6 @@ namespace Internal.Utilities.Collections -open System open System.Collections.Generic open Microsoft.FSharp.Collections diff --git a/src/utils/TaggedCollections.fs b/src/utils/TaggedCollections.fs index 232d3b75053..54f7e07fc5f 100644 --- a/src/utils/TaggedCollections.fs +++ b/src/utils/TaggedCollections.fs @@ -7,12 +7,8 @@ namespace Internal.Utilities.Collections.Tagged #nowarn "60" // override implementations in augmentations open Microsoft.FSharp.Core - open Microsoft.FSharp.Core.Operators open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators - open System open System.Collections.Generic - open Internal.Utilities - open Internal.Utilities.Collections [] diff --git a/src/utils/prim-parsing.fs b/src/utils/prim-parsing.fs index 9ce01bff907..43c5e6cb330 100644 --- a/src/utils/prim-parsing.fs +++ b/src/utils/prim-parsing.fs @@ -4,11 +4,9 @@ namespace Internal.Utilities.Text.Parsing -open Internal.Utilities open Internal.Utilities.Text.Lexing open System -open System.Collections.Generic exception RecoverableParseError exception Accept of obj diff --git a/src/utils/sformat.fs b/src/utils/sformat.fs index 42cb18fa8d0..21b84f5bef7 100644 --- a/src/utils/sformat.fs +++ b/src/utils/sformat.fs @@ -25,18 +25,14 @@ namespace Microsoft.FSharp.Text.StructuredPrintfImpl // This is a fresh implementation of pre-existing ideas. open System - open System.Diagnostics - open System.Text open System.IO open System.Reflection open System.Globalization open System.Collections.Generic open Microsoft.FSharp.Core open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators - open Microsoft.FSharp.Core.Operators open Microsoft.FSharp.Reflection open Microsoft.FSharp.Collections - open Microsoft.FSharp.Primitives.Basics [] type LayoutTag = @@ -342,8 +338,6 @@ namespace Microsoft.FSharp.Text.StructuredPrintfImpl module ReflectUtils = - open System - open System.Reflection [] type TypeInfo = diff --git a/tests/service/AssemblyReaderShim.fs b/tests/service/AssemblyReaderShim.fs index 329fce81989..71ad67809db 100644 --- a/tests/service/AssemblyReaderShim.fs +++ b/tests/service/AssemblyReaderShim.fs @@ -7,7 +7,6 @@ module FSharp.Compiler.Service.Tests.AssemblyReaderShim #endif -open FSharp.Compiler.Service.Tests.Common open FsUnit open FSharp.Compiler.AbstractIL.ILBinaryReader open NUnit.Framework diff --git a/tests/service/CSharpProjectAnalysis.fs b/tests/service/CSharpProjectAnalysis.fs index bac536c294b..8f787e90e5a 100644 --- a/tests/service/CSharpProjectAnalysis.fs +++ b/tests/service/CSharpProjectAnalysis.fs @@ -12,14 +12,8 @@ module FSharp.Compiler.Service.Tests.CSharpProjectAnalysis open NUnit.Framework open FsUnit -open System open System.IO -open System.Collections.Generic - -open FSharp.Compiler -open FSharp.Compiler.Service.Tests open FSharp.Compiler.SourceCodeServices - open FSharp.Compiler.Service.Tests.Common let internal getProjectReferences (content, dllFiles, libDirs, otherFlags) = diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 6920e682afe..1d45956d307 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -76,7 +76,6 @@ let sysLib nm = [] module Helpers = - open System type DummyType = A | B let PathRelativeToTestAssembly p = Path.Combine(Path.GetDirectoryName(Uri(typeof.Assembly.CodeBase).LocalPath), p) diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 69b9e407645..47f67fadea8 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -30,7 +30,6 @@ module Tests.Service.Editor open NUnit.Framework open FsUnit open System -open System.IO open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common diff --git a/tests/service/ExprTests.fs b/tests/service/ExprTests.fs index a92301bcefb..f2215974b95 100644 --- a/tests/service/ExprTests.fs +++ b/tests/service/ExprTests.fs @@ -15,9 +15,7 @@ open FsUnit open System open System.IO open System.Collections.Generic -open FSharp.Compiler open FSharp.Compiler.SourceCodeServices -open FSharp.Compiler.Service open FSharp.Compiler.Service.Tests.Common let internal exprChecker = FSharpChecker.Create(keepAssemblyContents=true) @@ -282,7 +280,6 @@ module internal Utils = // This project is a smoke test for a whole range of standard and obscure expressions module internal Project1 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2669,7 +2666,6 @@ let ``Test Operator Declarations for String`` () = // This big list expression was causing us trouble module internal ProjectStressBigExpressions = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() diff --git a/tests/service/FileSystemTests.fs b/tests/service/FileSystemTests.fs index 24b45414fd2..8580462c2b6 100644 --- a/tests/service/FileSystemTests.fs +++ b/tests/service/FileSystemTests.fs @@ -12,9 +12,7 @@ open NUnit.Framework open FsUnit open System open System.IO -open System.Collections.Generic open System.Text -open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.Service.Tests.Common diff --git a/tests/service/InteractiveCheckerTests.fs b/tests/service/InteractiveCheckerTests.fs index ea892fc1b5e..3d7e13769bd 100644 --- a/tests/service/InteractiveCheckerTests.fs +++ b/tests/service/InteractiveCheckerTests.fs @@ -12,7 +12,6 @@ open NUnit.Framework open FsUnit open System open FSharp.Compiler -open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let internal longIdentToString (longIdent: Ast.LongIdent) = diff --git a/tests/service/MultiProjectAnalysisTests.fs b/tests/service/MultiProjectAnalysisTests.fs index 04ba820da0d..26d430f5000 100644 --- a/tests/service/MultiProjectAnalysisTests.fs +++ b/tests/service/MultiProjectAnalysisTests.fs @@ -13,12 +13,8 @@ open FSharp.Compiler.SourceCodeServices open NUnit.Framework open FsUnit -open System open System.IO -open System -open System.Collections.Generic -open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common let numProjectsForStressTest = 100 @@ -29,7 +25,6 @@ let internal tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m. module internal Project1A = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() @@ -69,7 +64,6 @@ type U = //----------------------------------------------------------------------------------------- module internal Project1B = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() @@ -97,7 +91,6 @@ let x = // A project referencing two sub-projects module internal MultiProject1 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() @@ -248,7 +241,6 @@ let ``Test multi project 1 xmldoc`` () = // A project referencing many sub-projects module internal ManyProjectsStressTest = - open System.IO let numProjectsForStressTest = 100 @@ -390,7 +382,6 @@ let ``Test ManyProjectsStressTest all symbols`` () = //----------------------------------------------------------------------------------------- module internal MultiProjectDirty1 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() @@ -412,7 +403,6 @@ let x = "F#" checker.GetProjectOptionsFromCommandLineArgs (projFileName, args) module internal MultiProjectDirty2 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -608,7 +598,6 @@ let ``Test multi project symbols should pick up changes in dependent projects`` module internal Project2A = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName1 = Path.GetTempFileName() @@ -638,7 +627,6 @@ type C() = //Project2A.fileSource1 // A project referencing Project2A module internal Project2B = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let dllName = Path.ChangeExtension(Project2A.baseName2, ".dll") @@ -663,7 +651,6 @@ let v = Project2A.C().InternalMember // access an internal symbol //Project2A.fileSource1 // A project referencing Project2A but without access to the internals of A module internal Project2C = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let dllName = Path.ChangeExtension(Project2A.baseName3, ".dll") @@ -728,7 +715,6 @@ let ``Test multi project 2 all symbols`` () = //------------------------------------------------------------------------------------ module internal Project3A = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() @@ -752,7 +738,6 @@ let (|DivisibleBy|_|) by n = // A project referencing a sub-project module internal MultiProject3 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let baseName = Path.GetTempFileName() diff --git a/tests/service/PerfTests.fs b/tests/service/PerfTests.fs index c5f2afbc7af..ffffa412a36 100644 --- a/tests/service/PerfTests.fs +++ b/tests/service/PerfTests.fs @@ -10,11 +10,8 @@ module FSharp.Compiler.Service.Tests.PerfTests open NUnit.Framework open FsUnit -open System open System.IO -open System.Collections.Generic -open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common @@ -23,7 +20,6 @@ open FSharp.Compiler.Service.Tests.Common let internal checker = FSharpChecker.Create() module internal Project1 = - open System.IO let fileNamesI = [ for i in 1 .. 10 -> (i, Path.ChangeExtension(Path.GetTempFileName(), ".fs")) ] let base2 = Path.GetTempFileName() diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index c9635c70830..45b5dc1b50f 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -13,7 +13,6 @@ open NUnit.Framework open FsUnit open System open System.IO -open System.Collections.Generic open FSharp.Compiler open FSharp.Compiler.SourceCodeServices @@ -21,7 +20,6 @@ open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.Service.Tests.Common module internal Project1 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -639,7 +637,6 @@ let ``Test file explicit parse all symbols`` () = //----------------------------------------------------------------------------------------- module internal Project2 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -836,7 +833,6 @@ let ``Test project2 all uses of all symbols`` () = //----------------------------------------------------------------------------------------- module internal Project3 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1277,7 +1273,6 @@ let ``Test project3 all uses of all signature symbols`` () = //----------------------------------------------------------------------------------------- module internal Project4 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1432,7 +1427,6 @@ let ``Test project4 T symbols`` () = module internal Project5 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") @@ -1648,7 +1642,6 @@ let ``Test partial active patterns' exact ranges from uses of symbols`` () = //----------------------------------------------------------------------------------------- module internal Project6 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1702,7 +1695,6 @@ let ``Test project 6 all symbols`` () = //----------------------------------------------------------------------------------------- module internal Project7 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1764,7 +1756,6 @@ let ``Test project 7 all symbols`` () = //----------------------------------------------------------------------------------------- module internal Project8 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1849,7 +1840,6 @@ let ``Test project 8 all symbols`` () = //----------------------------------------------------------------------------------------- module internal Project9 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -1927,7 +1917,6 @@ let ``Test project 9 all symbols`` () = // see https://github.com/fsharp/FSharp.Compiler.Service/issues/95 module internal Project10 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2010,7 +1999,6 @@ let ``Test Project10 all symbols`` () = // see https://github.com/fsharp/FSharp.Compiler.Service/issues/92 module internal Project11 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2078,7 +2066,6 @@ let ``Test Project11 all symbols`` () = // see https://github.com/fsharp/FSharp.Compiler.Service/issues/92 module internal Project12 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2147,7 +2134,6 @@ let ``Test Project12 all symbols`` () = // Test fetching information about some external types (e.g. System.Object, System.DateTime) module internal Project13 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2296,7 +2282,6 @@ let ``Test Project13 all symbols`` () = // Misc - structs module internal Project14 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2365,7 +2350,6 @@ let ``Test Project14 all symbols`` () = // Misc - union patterns module internal Project15 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2425,7 +2409,6 @@ let ``Test Project15 all symbols`` () = // Misc - signature files module internal Project16 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let sigFileName1 = Path.ChangeExtension(fileName1, ".fsi") @@ -2725,7 +2708,6 @@ let ``Test project16 DeclaringEntity`` () = // Misc - namespace symbols module internal Project17 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2818,7 +2800,6 @@ let ``Test Project17 all symbols`` () = // Misc - generic type definnitions module internal Project18 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2869,7 +2850,6 @@ let ``Test Project18 all symbols`` () = // Misc - enums module internal Project19 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -2948,7 +2928,6 @@ let ``Test Project19 all symbols`` () = // Misc - https://github.com/fsharp/FSharp.Compiler.Service/issues/109 module internal Project20 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3001,7 +2980,6 @@ let ``Test Project20 all symbols`` () = // Misc - https://github.com/fsharp/FSharp.Compiler.Service/issues/137 module internal Project21 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3080,7 +3058,6 @@ let ``Test Project21 all symbols`` () = // Misc - namespace symbols module internal Project22 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3220,7 +3197,6 @@ let ``Test Project22 IList properties`` () = // Misc - properties module internal Project23 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3353,7 +3329,6 @@ let ``Test Project23 extension properties' getters/setters should refer to the c // Misc - property symbols module internal Project24 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3646,7 +3621,6 @@ let ``Test symbol uses of properties with both getters and setters`` () = #endif // Misc - type provider symbols module internal Project25 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3787,7 +3761,6 @@ let ``Test symbol uses of fully-qualified records`` () = module internal Project26 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3879,7 +3852,6 @@ let ``Test Project26 parameter symbols`` () = ("M3", None, "type Microsoft.FSharp.Core.unit", "")]) module internal Project27 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -3925,7 +3897,6 @@ let ``Test project27 all symbols in signature`` () = ("member AbstractMethod", ["member"; "overridemem"])] module internal Project28 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4028,7 +3999,6 @@ let ``Test project28 all symbols in signature`` () = ("FSharpGenericParameter", "?", "")|] #endif module internal Project29 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4085,7 +4055,6 @@ let ``Test project29 event symbols`` () = module internal Project30 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4146,7 +4115,6 @@ let ``Test project30 Format attributes`` () = """[]""")]) module internal Project31 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4264,7 +4232,6 @@ let ``Test project31 Format C# method attributes`` () = ]) module internal Project32 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let sigFileName1 = Path.ChangeExtension(fileName1, ".fsi") @@ -4337,7 +4304,6 @@ let ``Test Project32 should be able to find impl symbols`` () = ("file1", ((3, 4), (3, 8)), ["val"])] module internal Project33 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4383,7 +4349,6 @@ let ``Test Project33 extension methods`` () = ("GetValue", ["member"; "extmem"])] module internal Project34 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4448,7 +4413,6 @@ let ``Test project34 should report correct accessibility for System.Data.Listene //------------------------------------------------------ module internal Project35 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4526,7 +4490,6 @@ let ``Test project35 CurriedParameterGroups should be available for nested funct //------------------------------------------------------ module internal Project35b = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fsx") let fileSource1Text = """ @@ -4581,7 +4544,6 @@ let ``Test project35b Dependency files for check of project`` () = //------------------------------------------------------ module internal Project36 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4679,7 +4641,6 @@ let ``Test project36 FSharpMemberOrFunctionOrValue.LiteralValue`` () = shouldEqual true notLit.LiteralValue.IsNone module internal Project37 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4831,7 +4792,6 @@ let ``Test project37 DeclaringEntity`` () = module internal Project38 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -4929,7 +4889,6 @@ let ``Test project38 abstract slot information`` () = //-------------------------------------------- module internal Project39 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -5010,7 +4969,6 @@ let ``Test project39 all symbols`` () = //-------------------------------------------- module internal Project40 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -5075,7 +5033,6 @@ let ``Test Project40 all symbols`` () = //-------------------------------------------- module internal Project41 = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") // We need to us a stable name to keep the hashes stable @@ -5169,7 +5126,6 @@ let ``Test project41 all symbols`` () = module internal ProjectBig = - open System.IO let fileNamesI = [ for i in 1 .. 10 -> (i, Path.ChangeExtension(Path.GetTempFileName(), ".fs")) ] let base2 = Path.GetTempFileName() @@ -5206,7 +5162,6 @@ let ``add files with same name from different folders`` () = shouldEqual 0 errors.Length module internal ProjectStructUnions = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() @@ -5253,7 +5208,6 @@ let ``Test typed AST for struct unions`` () = // See https://github.com/fsharp/F |> shouldEqual true module internal ProjectLineDirectives = - open System.IO let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs") let base2 = Path.GetTempFileName() diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index de7aed16756..1b1e252055b 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -10,7 +10,6 @@ module FSharp.Compiler.Service.Tests.ProjectOptionsTests let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e -> false -open System open System.IO open NUnit.Framework open FsUnit diff --git a/tests/service/TokenizerTests.fs b/tests/service/TokenizerTests.fs index c03fbce9370..0827ff35027 100644 --- a/tests/service/TokenizerTests.fs +++ b/tests/service/TokenizerTests.fs @@ -8,14 +8,9 @@ module FSharp.Compiler.Service.Tests.TokenizerTests #endif -open FSharp.Compiler -open FSharp.Compiler.Interactive.Shell open FSharp.Compiler.SourceCodeServices open NUnit.Framework -open FsUnit -open System -open System.IO let sourceTok = FSharpSourceTokenizer([], Some "C:\\test.fsx") From 613fcae4115834cb0c56b26c13351060817bfaeb Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 27 Sep 2019 23:48:47 +0300 Subject: [PATCH 02/68] Remove unused opens --- fcs/samples/EditorService/Program.fs | 2 -- fcs/samples/FscExe/FscMain.fs | 2 -- fcs/samples/FsiExe/fsimain.fs | 2 -- fcs/samples/UntypedTree/Program.fs | 1 - 4 files changed, 7 deletions(-) diff --git a/fcs/samples/EditorService/Program.fs b/fcs/samples/EditorService/Program.fs index e3ab70185c3..d457bf17c91 100644 --- a/fcs/samples/EditorService/Program.fs +++ b/fcs/samples/EditorService/Program.fs @@ -1,6 +1,4 @@ // Open the namespace with InteractiveChecker type -open System -open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.QuickParse diff --git a/fcs/samples/FscExe/FscMain.fs b/fcs/samples/FscExe/FscMain.fs index 26f26be63d1..da272800d65 100644 --- a/fcs/samples/FscExe/FscMain.fs +++ b/fcs/samples/FscExe/FscMain.fs @@ -7,12 +7,10 @@ open System.Diagnostics open System.IO open System.Reflection open System.Runtime.CompilerServices -open FSharp.Compiler open FSharp.Compiler.SourceCodeServices open FSharp.Compiler.AbstractIL.IL // runningOnMono open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.ErrorLogger -open FSharp.Compiler.Range #if RESIDENT_COMPILER type TypeInThisAssembly() = member x.Dummy = 1 diff --git a/fcs/samples/FsiExe/fsimain.fs b/fcs/samples/FsiExe/fsimain.fs index c59ef2fe50f..5fb34c3af17 100644 --- a/fcs/samples/FsiExe/fsimain.fs +++ b/fcs/samples/FsiExe/fsimain.fs @@ -17,13 +17,11 @@ module internal Sample.FSharp.Compiler.Interactive.Main open System open System.Globalization -open System.IO open System.Reflection open System.Threading open System.Windows.Forms open FSharp.Compiler.Interactive.Shell -open FSharp.Compiler.Interactive open FSharp.Compiler #nowarn "55" diff --git a/fcs/samples/UntypedTree/Program.fs b/fcs/samples/UntypedTree/Program.fs index ba6afb2dd2b..9d99b8199f8 100644 --- a/fcs/samples/UntypedTree/Program.fs +++ b/fcs/samples/UntypedTree/Program.fs @@ -1,5 +1,4 @@ // Open the namespace with InteractiveChecker type -open System open FSharp.Compiler.SourceCodeServices From 1e1be1b1d424817f323a95d94f2a22ef3aef1c6d Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 25 Oct 2019 13:06:48 -0700 Subject: [PATCH 03/68] Initial work --- src/fsharp/IlxGen.fs | 27 +- tests/fsharp/Compiler/CompilerAssert.fs | 2 +- .../fsharp/Compiler/Stress/LargeExprTests.fs | 2025 +++++++++++++++++ 3 files changed, 2040 insertions(+), 14 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 62300df6766..d743c30e525 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -847,14 +847,14 @@ and IlxGenEnv = withinSEH: bool /// Are we inside of a recursive let binding, while loop, or a for loop? - isInLoop: bool + inLoop: bool } override __.ToString() = "" -let SetIsInLoop isInLoop eenv = - if eenv.isInLoop = isInLoop then eenv - else { eenv with isInLoop = isInLoop } +let SetInLoop inLoop eenv = + if eenv.inLoop = inLoop then eenv + else { eenv with inLoop = inLoop } let ReplaceTyenv tyenv (eenv: IlxGenEnv) = {eenv with tyenv = tyenv } @@ -1911,9 +1911,10 @@ let CodeGenThen cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, c let innerVals = entryPointInfo |> List.map (fun (v, kind) -> (v, (kind, start))) (* Call the given code generator *) - codeGenFunction cgbuf {eenv with withinSEH=false - liveLocals=IntMap.empty() - innerVals = innerVals} + codeGenFunction cgbuf { eenv with withinSEH = false + liveLocals = IntMap.empty() + innerVals = innerVals + inLoop = false } let locals, maxStack, lab2pc, code, exnSpecs, hasSequencePoints = cgbuf.Close() @@ -2196,7 +2197,7 @@ and GenExprWithStackGuard cenv cgbuf eenv sp expr sequel = assert (cenv.exprRecursionDepth = 1) with | :? System.InsufficientExecutionStackException -> - error(InternalError("Expression is too large and/or complex to emit.", expr.Range)) + error(InternalError(sprintf "Expression is too large and/or complex to emit. Method name: '%s'. Recursive depth: %i." cgbuf.MethodName cenv.exprRecursionDepth, expr.Range)) and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = let g = cenv.g @@ -3456,7 +3457,7 @@ and GenTryFinally cenv cgbuf eenv (bodyExpr, handlerExpr, m, resty, spTry, spFin //-------------------------------------------------------------------------- and GenForLoop cenv cgbuf eenv (spFor, v, e1, dir, e2, loopBody, m) sequel = - let eenv = SetIsInLoop true eenv + let eenv = SetInLoop true eenv let g = cenv.g // The JIT/NGen eliminate array-bounds checks for C# loops of form: @@ -3547,7 +3548,7 @@ and GenForLoop cenv cgbuf eenv (spFor, v, e1, dir, e2, loopBody, m) sequel = //-------------------------------------------------------------------------- and GenWhileLoop cenv cgbuf eenv (spWhile, e1, e2, m) sequel = - let eenv = SetIsInLoop true eenv + let eenv = SetInLoop true eenv let finish = CG.GenerateDelayMark cgbuf "while_finish" let startTest = CG.GenerateMark cgbuf "startTest" @@ -5150,7 +5151,7 @@ and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFi /// Generate letrec bindings and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) = - let eenv = SetIsInLoop true eenv + let eenv = SetInLoop true eenv // Fix up recursion for non-toplevel recursive bindings let bindsPossiblyRequiringFixup = allBinds |> List.filter (fun b -> @@ -5400,7 +5401,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec, rhsExpr, _)) s let storage = StorageForVal cenv.g m vspec eenv match storage, rhsExpr with // locals are zero-init, no need to initialize them, except if you are in a loop and the local is mutable. - | Local (_, realloc, _), Expr.Const (Const.Zero, _, _) when not realloc && not (eenv.isInLoop && vspec.IsMutable) -> + | Local (_, realloc, _), Expr.Const (Const.Zero, _, _) when not realloc && not (eenv.inLoop && vspec.IsMutable) -> CommitStartScope cgbuf startScopeMarkOpt | _ -> GenBindingRhs cenv cgbuf eenv SPSuppress vspec rhsExpr @@ -7535,7 +7536,7 @@ let GetEmptyIlxGenEnv (ilg: ILGlobals) ccu = innerVals = [] sigToImplRemapInfo = [] (* "module remap info" *) withinSEH = false - isInLoop = false } + inLoop = false } type IlxGenResults = { ilTypeDefs: ILTypeDef list diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index 50102ab21c4..f4f5e008f00 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -143,7 +143,7 @@ let main argv = 0""" ProjectId = None SourceFiles = [|"test.fs"|] #if !NETCOREAPP - OtherOptions = [|"--preferreduilang:en-US";"--warn:5"|] + OtherOptions = [|"--preferreduilang:en-US";"--warn:5";"--optimize-"|] #else OtherOptions = let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x) diff --git a/tests/fsharp/Compiler/Stress/LargeExprTests.fs b/tests/fsharp/Compiler/Stress/LargeExprTests.fs index 572c0e53550..004f737cb9c 100644 --- a/tests/fsharp/Compiler/Stress/LargeExprTests.fs +++ b/tests/fsharp/Compiler/Stress/LargeExprTests.fs @@ -1015,6 +1015,2031 @@ type TestRecord = test1000: int } +[] +let main _ = 0 + """ + + [] + let LargeRecordWithStringFieldsDoesNotStackOverflow() = + CompilerAssert.CompileExe + """ +type TestRecord = + { + test1: string + test2: string + test3: string + test4: string + test5: string + test6: string + test7: string + test8: string + test9: string + test10: string + test11: string + test12: string + test13: string + test14: string + test15: string + test16: string + test17: string + test18: string + test19: string + test20: string + test21: string + test22: string + test23: string + test24: string + test25: string + test26: string + test27: string + test28: string + test29: string + test30: string + test31: string + test32: string + test33: string + test34: string + test35: string + test36: string + test37: string + test38: string + test39: string + test40: string + test41: string + test42: string + test43: string + test44: string + test45: string + test46: string + test47: string + test48: string + test49: string + test50: string + test51: string + test52: string + test53: string + test54: string + test55: string + test56: string + test57: string + test58: string + test59: string + test60: string + test61: string + test62: string + test63: string + test64: string + test65: string + test66: string + test67: string + test68: string + test69: string + test70: string + test71: string + test72: string + test73: string + test74: string + test75: string + test76: string + test77: string + test78: string + test79: string + test80: string + test81: string + test82: string + test83: string + test84: string + test85: string + test86: string + test87: string + test88: string + test89: string + test90: string + test91: string + test92: string + test93: string + test94: string + test95: string + test96: string + test97: string + test98: string + test99: string + test100: string + test101: string + test102: string + test103: string + test104: string + test105: string + test106: string + test107: string + test108: string + test109: string + test110: string + test111: string + test112: string + test113: string + test114: string + test115: string + test116: string + test117: string + test118: string + test119: string + test120: string + test121: string + test122: string + test123: string + test124: string + test125: string + test126: string + test127: string + test128: string + test129: string + test130: string + test131: string + test132: string + test133: string + test134: string + test135: string + test136: string + test137: string + test138: string + test139: string + test140: string + test141: string + test142: string + test143: string + test144: string + test145: string + test146: string + test147: string + test148: string + test149: string + test150: string + test151: string + test152: string + test153: string + test154: string + test155: string + test156: string + test157: string + test158: string + test159: string + test160: string + test161: string + test162: string + test163: string + test164: string + test165: string + test166: string + test167: string + test168: string + test169: string + test170: string + test171: string + test172: string + test173: string + test174: string + test175: string + test176: string + test177: string + test178: string + test179: string + test180: string + test181: string + test182: string + test183: string + test184: string + test185: string + test186: string + test187: string + test188: string + test189: string + test190: string + test191: string + test192: string + test193: string + test194: string + test195: string + test196: string + test197: string + test198: string + test199: string + test200: string + test201: string + test202: string + test203: string + test204: string + test205: string + test206: string + test207: string + test208: string + test209: string + test210: string + test211: string + test212: string + test213: string + test214: string + test215: string + test216: string + test217: string + test218: string + test219: string + test220: string + test221: string + test222: string + test223: string + test224: string + test225: string + test226: string + test227: string + test228: string + test229: string + test230: string + test231: string + test232: string + test233: string + test234: string + test235: string + test236: string + test237: string + test238: string + test239: string + test240: string + test241: string + test242: string + test243: string + test244: string + test245: string + test246: string + test247: string + test248: string + test249: string + test250: string + test251: string + test252: string + test253: string + test254: string + test255: string + test256: string + test257: string + test258: string + test259: string + test260: string + test261: string + test262: string + test263: string + test264: string + test265: string + test266: string + test267: string + test268: string + test269: string + test270: string + test271: string + test272: string + test273: string + test274: string + test275: string + test276: string + test277: string + test278: string + test279: string + test280: string + test281: string + test282: string + test283: string + test284: string + test285: string + test286: string + test287: string + test288: string + test289: string + test290: string + test291: string + test292: string + test293: string + test294: string + test295: string + test296: string + test297: string + test298: string + test299: string + test300: string + test301: string + test302: string + test303: string + test304: string + test305: string + test306: string + test307: string + test308: string + test309: string + test310: string + test311: string + test312: string + test313: string + test314: string + test315: string + test316: string + test317: string + test318: string + test319: string + test320: string + test321: string + test322: string + test323: string + test324: string + test325: string + test326: string + test327: string + test328: string + test329: string + test330: string + test331: string + test332: string + test333: string + test334: string + test335: string + test336: string + test337: string + test338: string + test339: string + test340: string + test341: string + test342: string + test343: string + test344: string + test345: string + test346: string + test347: string + test348: string + test349: string + test350: string + test351: string + test352: string + test353: string + test354: string + test355: string + test356: string + test357: string + test358: string + test359: string + test360: string + test361: string + test362: string + test363: string + test364: string + test365: string + test366: string + test367: string + test368: string + test369: string + test370: string + test371: string + test372: string + test373: string + test374: string + test375: string + test376: string + test377: string + test378: string + test379: string + test380: string + test381: string + test382: string + test383: string + test384: string + test385: string + test386: string + test387: string + test388: string + test389: string + test390: string + test391: string + test392: string + test393: string + test394: string + test395: string + test396: string + test397: string + test398: string + test399: string + test400: string + test401: string + test402: string + test403: string + test404: string + test405: string + test406: string + test407: string + test408: string + test409: string + test410: string + test411: string + test412: string + test413: string + test414: string + test415: string + test416: string + test417: string + test418: string + test419: string + test420: string + test421: string + test422: string + test423: string + test424: string + test425: string + test426: string + test427: string + test428: string + test429: string + test430: string + test431: string + test432: string + test433: string + test434: string + test435: string + test436: string + test437: string + test438: string + test439: string + test440: string + test441: string + test442: string + test443: string + test444: string + test445: string + test446: string + test447: string + test448: string + test449: string + test450: string + test451: string + test452: string + test453: string + test454: string + test455: string + test456: string + test457: string + test458: string + test459: string + test460: string + test461: string + test462: string + test463: string + test464: string + test465: string + test466: string + test467: string + test468: string + test469: string + test470: string + test471: string + test472: string + test473: string + test474: string + test475: string + test476: string + test477: string + test478: string + test479: string + test480: string + test481: string + test482: string + test483: string + test484: string + test485: string + test486: string + test487: string + test488: string + test489: string + test490: string + test491: string + test492: string + test493: string + test494: string + test495: string + test496: string + test497: string + test498: string + test499: string + test500: string + test501: string + test502: string + test503: string + test504: string + test505: string + test506: string + test507: string + test508: string + test509: string + test510: string + test511: string + test512: string + test513: string + test514: string + test515: string + test516: string + test517: string + test518: string + test519: string + test520: string + test521: string + test522: string + test523: string + test524: string + test525: string + test526: string + test527: string + test528: string + test529: string + test530: string + test531: string + test532: string + test533: string + test534: string + test535: string + test536: string + test537: string + test538: string + test539: string + test540: string + test541: string + test542: string + test543: string + test544: string + test545: string + test546: string + test547: string + test548: string + test549: string + test550: string + test551: string + test552: string + test553: string + test554: string + test555: string + test556: string + test557: string + test558: string + test559: string + test560: string + test561: string + test562: string + test563: string + test564: string + test565: string + test566: string + test567: string + test568: string + test569: string + test570: string + test571: string + test572: string + test573: string + test574: string + test575: string + test576: string + test577: string + test578: string + test579: string + test580: string + test581: string + test582: string + test583: string + test584: string + test585: string + test586: string + test587: string + test588: string + test589: string + test590: string + test591: string + test592: string + test593: string + test594: string + test595: string + test596: string + test597: string + test598: string + test599: string + test600: string + test601: string + test602: string + test603: string + test604: string + test605: string + test606: string + test607: string + test608: string + test609: string + test610: string + test611: string + test612: string + test613: string + test614: string + test615: string + test616: string + test617: string + test618: string + test619: string + test620: string + test621: string + test622: string + test623: string + test624: string + test625: string + test626: string + test627: string + test628: string + test629: string + test630: string + test631: string + test632: string + test633: string + test634: string + test635: string + test636: string + test637: string + test638: string + test639: string + test640: string + test641: string + test642: string + test643: string + test644: string + test645: string + test646: string + test647: string + test648: string + test649: string + test650: string + test651: string + test652: string + test653: string + test654: string + test655: string + test656: string + test657: string + test658: string + test659: string + test660: string + test661: string + test662: string + test663: string + test664: string + test665: string + test666: string + test667: string + test668: string + test669: string + test670: string + test671: string + test672: string + test673: string + test674: string + test675: string + test676: string + test677: string + test678: string + test679: string + test680: string + test681: string + test682: string + test683: string + test684: string + test685: string + test686: string + test687: string + test688: string + test689: string + test690: string + test691: string + test692: string + test693: string + test694: string + test695: string + test696: string + test697: string + test698: string + test699: string + test700: string + test701: string + test702: string + test703: string + test704: string + test705: string + test706: string + test707: string + test708: string + test709: string + test710: string + test711: string + test712: string + test713: string + test714: string + test715: string + test716: string + test717: string + test718: string + test719: string + test720: string + test721: string + test722: string + test723: string + test724: string + test725: string + test726: string + test727: string + test728: string + test729: string + test730: string + test731: string + test732: string + test733: string + test734: string + test735: string + test736: string + test737: string + test738: string + test739: string + test740: string + test741: string + test742: string + test743: string + test744: string + test745: string + test746: string + test747: string + test748: string + test749: string + test750: string + test751: string + test752: string + test753: string + test754: string + test755: string + test756: string + test757: string + test758: string + test759: string + test760: string + test761: string + test762: string + test763: string + test764: string + test765: string + test766: string + test767: string + test768: string + test769: string + test770: string + test771: string + test772: string + test773: string + test774: string + test775: string + test776: string + test777: string + test778: string + test779: string + test780: string + test781: string + test782: string + test783: string + test784: string + test785: string + test786: string + test787: string + test788: string + test789: string + test790: string + test791: string + test792: string + test793: string + test794: string + test795: string + test796: string + test797: string + test798: string + test799: string + test800: string + test801: string + test802: string + test803: string + test804: string + test805: string + test806: string + test807: string + test808: string + test809: string + test810: string + test811: string + test812: string + test813: string + test814: string + test815: string + test816: string + test817: string + test818: string + test819: string + test820: string + test821: string + test822: string + test823: string + test824: string + test825: string + test826: string + test827: string + test828: string + test829: string + test830: string + test831: string + test832: string + test833: string + test834: string + test835: string + test836: string + test837: string + test838: string + test839: string + test840: string + test841: string + test842: string + test843: string + test844: string + test845: string + test846: string + test847: string + test848: string + test849: string + test850: string + test851: string + test852: string + test853: string + test854: string + test855: string + test856: string + test857: string + test858: string + test859: string + test860: string + test861: string + test862: string + test863: string + test864: string + test865: string + test866: string + test867: string + test868: string + test869: string + test870: string + test871: string + test872: string + test873: string + test874: string + test875: string + test876: string + test877: string + test878: string + test879: string + test880: string + test881: string + test882: string + test883: string + test884: string + test885: string + test886: string + test887: string + test888: string + test889: string + test890: string + test891: string + test892: string + test893: string + test894: string + test895: string + test896: string + test897: string + test898: string + test899: string + test900: string + test901: string + test902: string + test903: string + test904: string + test905: string + test906: string + test907: string + test908: string + test909: string + test910: string + test911: string + test912: string + test913: string + test914: string + test915: string + test916: string + test917: string + test918: string + test919: string + test920: string + test921: string + test922: string + test923: string + test924: string + test925: string + test926: string + test927: string + test928: string + test929: string + test930: string + test931: string + test932: string + test933: string + test934: string + test935: string + test936: string + test937: string + test938: string + test939: string + test940: string + test941: string + test942: string + test943: string + test944: string + test945: string + test946: string + test947: string + test948: string + test949: string + test950: string + test951: string + test952: string + test953: string + test954: string + test955: string + test956: string + test957: string + test958: string + test959: string + test960: string + test961: string + test962: string + test963: string + test964: string + test965: string + test966: string + test967: string + test968: string + test969: string + test970: string + test971: string + test972: string + test973: string + test974: string + test975: string + test976: string + test977: string + test978: string + test979: string + test980: string + test981: string + test982: string + test983: string + test984: string + test985: string + test986: string + test987: string + test988: string + test989: string + test990: string + test991: string + test992: string + test993: string + test994: string + test995: string + test996: string + test997: string + test998: string + test999: string + test1000: string + } + +[] +let main _ = 0 + """ + + [] + let LargeStructRecordDoesNotStackOverflow() = + CompilerAssert.CompileExe + """ +[] +type TestRecord = + { + test1: int + test2: int + test3: int + test4: int + test5: int + test6: int + test7: int + test8: int + test9: int + test10: int + test11: int + test12: int + test13: int + test14: int + test15: int + test16: int + test17: int + test18: int + test19: int + test20: int + test21: int + test22: int + test23: int + test24: int + test25: int + test26: int + test27: int + test28: int + test29: int + test30: int + test31: int + test32: int + test33: int + test34: int + test35: int + test36: int + test37: int + test38: int + test39: int + test40: int + test41: int + test42: int + test43: int + test44: int + test45: int + test46: int + test47: int + test48: int + test49: int + test50: int + test51: int + test52: int + test53: int + test54: int + test55: int + test56: int + test57: int + test58: int + test59: int + test60: int + test61: int + test62: int + test63: int + test64: int + test65: int + test66: int + test67: int + test68: int + test69: int + test70: int + test71: int + test72: int + test73: int + test74: int + test75: int + test76: int + test77: int + test78: int + test79: int + test80: int + test81: int + test82: int + test83: int + test84: int + test85: int + test86: int + test87: int + test88: int + test89: int + test90: int + test91: int + test92: int + test93: int + test94: int + test95: int + test96: int + test97: int + test98: int + test99: int + test100: int + test101: int + test102: int + test103: int + test104: int + test105: int + test106: int + test107: int + test108: int + test109: int + test110: int + test111: int + test112: int + test113: int + test114: int + test115: int + test116: int + test117: int + test118: int + test119: int + test120: int + test121: int + test122: int + test123: int + test124: int + test125: int + test126: int + test127: int + test128: int + test129: int + test130: int + test131: int + test132: int + test133: int + test134: int + test135: int + test136: int + test137: int + test138: int + test139: int + test140: int + test141: int + test142: int + test143: int + test144: int + test145: int + test146: int + test147: int + test148: int + test149: int + test150: int + test151: int + test152: int + test153: int + test154: int + test155: int + test156: int + test157: int + test158: int + test159: int + test160: int + test161: int + test162: int + test163: int + test164: int + test165: int + test166: int + test167: int + test168: int + test169: int + test170: int + test171: int + test172: int + test173: int + test174: int + test175: int + test176: int + test177: int + test178: int + test179: int + test180: int + test181: int + test182: int + test183: int + test184: int + test185: int + test186: int + test187: int + test188: int + test189: int + test190: int + test191: int + test192: int + test193: int + test194: int + test195: int + test196: int + test197: int + test198: int + test199: int + test200: int + test201: int + test202: int + test203: int + test204: int + test205: int + test206: int + test207: int + test208: int + test209: int + test210: int + test211: int + test212: int + test213: int + test214: int + test215: int + test216: int + test217: int + test218: int + test219: int + test220: int + test221: int + test222: int + test223: int + test224: int + test225: int + test226: int + test227: int + test228: int + test229: int + test230: int + test231: int + test232: int + test233: int + test234: int + test235: int + test236: int + test237: int + test238: int + test239: int + test240: int + test241: int + test242: int + test243: int + test244: int + test245: int + test246: int + test247: int + test248: int + test249: int + test250: int + test251: int + test252: int + test253: int + test254: int + test255: int + test256: int + test257: int + test258: int + test259: int + test260: int + test261: int + test262: int + test263: int + test264: int + test265: int + test266: int + test267: int + test268: int + test269: int + test270: int + test271: int + test272: int + test273: int + test274: int + test275: int + test276: int + test277: int + test278: int + test279: int + test280: int + test281: int + test282: int + test283: int + test284: int + test285: int + test286: int + test287: int + test288: int + test289: int + test290: int + test291: int + test292: int + test293: int + test294: int + test295: int + test296: int + test297: int + test298: int + test299: int + test300: int + test301: int + test302: int + test303: int + test304: int + test305: int + test306: int + test307: int + test308: int + test309: int + test310: int + test311: int + test312: int + test313: int + test314: int + test315: int + test316: int + test317: int + test318: int + test319: int + test320: int + test321: int + test322: int + test323: int + test324: int + test325: int + test326: int + test327: int + test328: int + test329: int + test330: int + test331: int + test332: int + test333: int + test334: int + test335: int + test336: int + test337: int + test338: int + test339: int + test340: int + test341: int + test342: int + test343: int + test344: int + test345: int + test346: int + test347: int + test348: int + test349: int + test350: int + test351: int + test352: int + test353: int + test354: int + test355: int + test356: int + test357: int + test358: int + test359: int + test360: int + test361: int + test362: int + test363: int + test364: int + test365: int + test366: int + test367: int + test368: int + test369: int + test370: int + test371: int + test372: int + test373: int + test374: int + test375: int + test376: int + test377: int + test378: int + test379: int + test380: int + test381: int + test382: int + test383: int + test384: int + test385: int + test386: int + test387: int + test388: int + test389: int + test390: int + test391: int + test392: int + test393: int + test394: int + test395: int + test396: int + test397: int + test398: int + test399: int + test400: int + test401: int + test402: int + test403: int + test404: int + test405: int + test406: int + test407: int + test408: int + test409: int + test410: int + test411: int + test412: int + test413: int + test414: int + test415: int + test416: int + test417: int + test418: int + test419: int + test420: int + test421: int + test422: int + test423: int + test424: int + test425: int + test426: int + test427: int + test428: int + test429: int + test430: int + test431: int + test432: int + test433: int + test434: int + test435: int + test436: int + test437: int + test438: int + test439: int + test440: int + test441: int + test442: int + test443: int + test444: int + test445: int + test446: int + test447: int + test448: int + test449: int + test450: int + test451: int + test452: int + test453: int + test454: int + test455: int + test456: int + test457: int + test458: int + test459: int + test460: int + test461: int + test462: int + test463: int + test464: int + test465: int + test466: int + test467: int + test468: int + test469: int + test470: int + test471: int + test472: int + test473: int + test474: int + test475: int + test476: int + test477: int + test478: int + test479: int + test480: int + test481: int + test482: int + test483: int + test484: int + test485: int + test486: int + test487: int + test488: int + test489: int + test490: int + test491: int + test492: int + test493: int + test494: int + test495: int + test496: int + test497: int + test498: int + test499: int + test500: int + test501: int + test502: int + test503: int + test504: int + test505: int + test506: int + test507: int + test508: int + test509: int + test510: int + test511: int + test512: int + test513: int + test514: int + test515: int + test516: int + test517: int + test518: int + test519: int + test520: int + test521: int + test522: int + test523: int + test524: int + test525: int + test526: int + test527: int + test528: int + test529: int + test530: int + test531: int + test532: int + test533: int + test534: int + test535: int + test536: int + test537: int + test538: int + test539: int + test540: int + test541: int + test542: int + test543: int + test544: int + test545: int + test546: int + test547: int + test548: int + test549: int + test550: int + test551: int + test552: int + test553: int + test554: int + test555: int + test556: int + test557: int + test558: int + test559: int + test560: int + test561: int + test562: int + test563: int + test564: int + test565: int + test566: int + test567: int + test568: int + test569: int + test570: int + test571: int + test572: int + test573: int + test574: int + test575: int + test576: int + test577: int + test578: int + test579: int + test580: int + test581: int + test582: int + test583: int + test584: int + test585: int + test586: int + test587: int + test588: int + test589: int + test590: int + test591: int + test592: int + test593: int + test594: int + test595: int + test596: int + test597: int + test598: int + test599: int + test600: int + test601: int + test602: int + test603: int + test604: int + test605: int + test606: int + test607: int + test608: int + test609: int + test610: int + test611: int + test612: int + test613: int + test614: int + test615: int + test616: int + test617: int + test618: int + test619: int + test620: int + test621: int + test622: int + test623: int + test624: int + test625: int + test626: int + test627: int + test628: int + test629: int + test630: int + test631: int + test632: int + test633: int + test634: int + test635: int + test636: int + test637: int + test638: int + test639: int + test640: int + test641: int + test642: int + test643: int + test644: int + test645: int + test646: int + test647: int + test648: int + test649: int + test650: int + test651: int + test652: int + test653: int + test654: int + test655: int + test656: int + test657: int + test658: int + test659: int + test660: int + test661: int + test662: int + test663: int + test664: int + test665: int + test666: int + test667: int + test668: int + test669: int + test670: int + test671: int + test672: int + test673: int + test674: int + test675: int + test676: int + test677: int + test678: int + test679: int + test680: int + test681: int + test682: int + test683: int + test684: int + test685: int + test686: int + test687: int + test688: int + test689: int + test690: int + test691: int + test692: int + test693: int + test694: int + test695: int + test696: int + test697: int + test698: int + test699: int + test700: int + test701: int + test702: int + test703: int + test704: int + test705: int + test706: int + test707: int + test708: int + test709: int + test710: int + test711: int + test712: int + test713: int + test714: int + test715: int + test716: int + test717: int + test718: int + test719: int + test720: int + test721: int + test722: int + test723: int + test724: int + test725: int + test726: int + test727: int + test728: int + test729: int + test730: int + test731: int + test732: int + test733: int + test734: int + test735: int + test736: int + test737: int + test738: int + test739: int + test740: int + test741: int + test742: int + test743: int + test744: int + test745: int + test746: int + test747: int + test748: int + test749: int + test750: int + test751: int + test752: int + test753: int + test754: int + test755: int + test756: int + test757: int + test758: int + test759: int + test760: int + test761: int + test762: int + test763: int + test764: int + test765: int + test766: int + test767: int + test768: int + test769: int + test770: int + test771: int + test772: int + test773: int + test774: int + test775: int + test776: int + test777: int + test778: int + test779: int + test780: int + test781: int + test782: int + test783: int + test784: int + test785: int + test786: int + test787: int + test788: int + test789: int + test790: int + test791: int + test792: int + test793: int + test794: int + test795: int + test796: int + test797: int + test798: int + test799: int + test800: int + test801: int + test802: int + test803: int + test804: int + test805: int + test806: int + test807: int + test808: int + test809: int + test810: int + test811: int + test812: int + test813: int + test814: int + test815: int + test816: int + test817: int + test818: int + test819: int + test820: int + test821: int + test822: int + test823: int + test824: int + test825: int + test826: int + test827: int + test828: int + test829: int + test830: int + test831: int + test832: int + test833: int + test834: int + test835: int + test836: int + test837: int + test838: int + test839: int + test840: int + test841: int + test842: int + test843: int + test844: int + test845: int + test846: int + test847: int + test848: int + test849: int + test850: int + test851: int + test852: int + test853: int + test854: int + test855: int + test856: int + test857: int + test858: int + test859: int + test860: int + test861: int + test862: int + test863: int + test864: int + test865: int + test866: int + test867: int + test868: int + test869: int + test870: int + test871: int + test872: int + test873: int + test874: int + test875: int + test876: int + test877: int + test878: int + test879: int + test880: int + test881: int + test882: int + test883: int + test884: int + test885: int + test886: int + test887: int + test888: int + test889: int + test890: int + test891: int + test892: int + test893: int + test894: int + test895: int + test896: int + test897: int + test898: int + test899: int + test900: int + test901: int + test902: int + test903: int + test904: int + test905: int + test906: int + test907: int + test908: int + test909: int + test910: int + test911: int + test912: int + test913: int + test914: int + test915: int + test916: int + test917: int + test918: int + test919: int + test920: int + test921: int + test922: int + test923: int + test924: int + test925: int + test926: int + test927: int + test928: int + test929: int + test930: int + test931: int + test932: int + test933: int + test934: int + test935: int + test936: int + test937: int + test938: int + test939: int + test940: int + test941: int + test942: int + test943: int + test944: int + test945: int + test946: int + test947: int + test948: int + test949: int + test950: int + test951: int + test952: int + test953: int + test954: int + test955: int + test956: int + test957: int + test958: int + test959: int + test960: int + test961: int + test962: int + test963: int + test964: int + test965: int + test966: int + test967: int + test968: int + test969: int + test970: int + test971: int + test972: int + test973: int + test974: int + test975: int + test976: int + test977: int + test978: int + test979: int + test980: int + test981: int + test982: int + test983: int + test984: int + test985: int + test986: int + test987: int + test988: int + test989: int + test990: int + test991: int + test992: int + test993: int + test994: int + test995: int + test996: int + test997: int + test998: int + test999: int + test1000: int + } + [] let main _ = 0 """ From 2b1e29cf2bb96b1a87cba68b32594b5270e800a1 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 25 Oct 2019 14:05:30 -0700 Subject: [PATCH 04/68] Quick re-name for OptimizeMethod(s) to OptimizeObjectExprMethod(s). --- src/fsharp/Optimizer.fs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index e89f3e4284b..f1df754803e 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -1932,7 +1932,7 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr = /// Optimize/analyze an object expression and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m) = let basecallR, basecallinfo = OptimizeExpr cenv env basecall - let overridesR, overrideinfos = OptimizeMethods cenv env baseValOpt overrides + let overridesR, overrideinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides let iimplsR, iimplsinfos = OptimizeInterfaceImpls cenv env baseValOpt iimpls let exprR=mkObjExpr(ty, baseValOpt, basecallR, overridesR, iimplsR, m) exprR, { TotalSize=closureTotalSize + basecallinfo.TotalSize + AddTotalSizes overrideinfos + AddTotalSizes iimplsinfos @@ -1942,10 +1942,10 @@ and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m) Info=UnknownValue} /// Optimize/analyze the methods that make up an object expression -and OptimizeMethods cenv env baseValOpt methods = - OptimizeList (OptimizeMethod cenv env baseValOpt) methods +and OptimizeObjectExprMethods cenv env baseValOpt methods = + OptimizeList (OptimizeObjectExprMethod cenv env baseValOpt) methods -and OptimizeMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) = +and OptimizeObjectExprMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) = let env = {env with latestBoundId=Some tmethod.Id; functionVal = None} let env = BindTypeVarsToUnknown tps env let env = BindInternalValsToUnknown cenv vs env @@ -1965,7 +1965,7 @@ and OptimizeInterfaceImpls cenv env baseValOpt iimpls = /// Optimize/analyze the interface implementations that form part of an object expression and OptimizeInterfaceImpl cenv env baseValOpt (ty, overrides) = - let overridesR, overridesinfos = OptimizeMethods cenv env baseValOpt overrides + let overridesR, overridesinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides (ty, overridesR), { TotalSize = AddTotalSizes overridesinfos FunctionSize = 1 From 0a6764ab46b1b7d5528e8c4ea100b225d8a464af Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 25 Oct 2019 17:19:04 -0700 Subject: [PATCH 05/68] Delaying lambdas working --- src/fsharp/CompileOptions.fs | 2 +- src/fsharp/IlxGen.fs | 114 ++++++++++++++++++----------------- src/fsharp/Optimizer.fs | 21 ++++++- src/fsharp/Optimizer.fsi | 4 ++ 4 files changed, 84 insertions(+), 57 deletions(-) diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index c4595d2dc24..c7ef18c94b8 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -395,7 +395,7 @@ let SetOptimizeOn(tcConfigB: TcConfigBuilder) = tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some true } tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true } tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some true } - tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = 6 } + tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = Optimizer.LambdaInlineThresholdDefault } tcConfigB.doDetuple <- true tcConfigB.doTLR <- true tcConfigB.doFinalSimplify <- true diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index d743c30e525..857365a6fca 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2353,9 +2353,7 @@ and CodeGenMethodForExpr cenv mgbuf (spReq, entryPointInfo, methodName, eenv, al CodeGenMethod cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, (fun cgbuf eenv -> GenExpr cenv cgbuf eenv spReq expr0 sequel0), expr0.Range) - code - - + code //-------------------------------------------------------------------------- // Generate sequels @@ -4305,9 +4303,65 @@ and GenGenericParams cenv eenv tps = and GenGenericArgs m (tyenv: TypeReprEnv) tps = tps |> DropErasedTypars |> List.map (fun c -> (mkILTyvarTy tyenv.[c, m])) +and DelayGenMethodForLambda cenv mgbuf eenv args = + cenv.delayedGenMethods.Enqueue(fun cenv -> GenMethodForLambda cenv mgbuf eenv args) + +and GenMethodForLambda cenv mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) = + let g = cenv.g + let ilCloBody = CodeGenMethodForExpr cenv mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return) + let ilCloTypeRef = cloinfo.cloSpec.TypeRef + let cloTypeDefs = + if isLocalTypeFunc then + + // Work out the contract type and generate a class with an abstract method for this type + let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo + let ilContractTypeRef = ilContractTySpec.TypeRef + let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams + let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object + + let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ] + let ilContractTypeDef = + ILTypeDef(name = ilContractTypeRef.Name, + layout = ILTypeDefLayout.Auto, + attributes = enum 0, + genericParams = ilContractGenericParams, + customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ], + fields = emptyILFields, + events= emptyILEvents, + properties = emptyILProperties, + methods= mkILMethods ilContractMeths, + methodImpls= emptyILMethodImpls, + nestedTypes=emptyILTypeDefs, + implements = [], + extends= Some g.ilg.typ_Object, + securityDecls= emptyILSecurityDecls) + + // the contract type is an abstract type and not sealed + let ilContractTypeDef = + ilContractTypeDef + .WithAbstract(true) + .WithAccess(ComputeTypeAccess ilContractTypeRef true) + .WithSerializable(true) + .WithSpecialName(true) + .WithLayout(ILTypeDefLayout.Auto) + .WithInitSemantics(ILTypeInit.BeforeField) + .WithEncoding(ILDefaultPInvokeEncoding.Auto) + + mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None) + + let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None ) + let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ] + let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, []) + cloTypeDefs + + else + GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, []) + CountClosure() + for cloTypeDef in cloTypeDefs do + mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None) + /// Generate the closure class for a function and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr = - let g = cenv.g match expr with | Expr.Lambda (_, _, _, _, _, m, _) | Expr.TyLambda (_, _, _, m, _) -> @@ -4319,57 +4373,7 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr | Some v -> [(v, BranchCallClosure (cloinfo.cloArityInfo))] | _ -> [] - let ilCloBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return) - let ilCloTypeRef = cloinfo.cloSpec.TypeRef - let cloTypeDefs = - if isLocalTypeFunc then - - // Work out the contract type and generate a class with an abstract method for this type - let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo - let ilContractTypeRef = ilContractTySpec.TypeRef - let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams - let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object - - let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ] - let ilContractTypeDef = - ILTypeDef(name = ilContractTypeRef.Name, - layout = ILTypeDefLayout.Auto, - attributes = enum 0, - genericParams = ilContractGenericParams, - customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ], - fields = emptyILFields, - events= emptyILEvents, - properties = emptyILProperties, - methods= mkILMethods ilContractMeths, - methodImpls= emptyILMethodImpls, - nestedTypes=emptyILTypeDefs, - implements = [], - extends= Some g.ilg.typ_Object, - securityDecls= emptyILSecurityDecls) - - // the contract type is an abstract type and not sealed - let ilContractTypeDef = - ilContractTypeDef - .WithAbstract(true) - .WithAccess(ComputeTypeAccess ilContractTypeRef true) - .WithSerializable(true) - .WithSpecialName(true) - .WithLayout(ILTypeDefLayout.Auto) - .WithInitSemantics(ILTypeInit.BeforeField) - .WithEncoding(ILDefaultPInvokeEncoding.Auto) - - cgbuf.mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None) - - let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None ) - let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ] - let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, []) - cloTypeDefs - - else - GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, []) - CountClosure() - for cloTypeDef in cloTypeDefs do - cgbuf.mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None) + DelayGenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) cloinfo, m | _ -> failwith "GenLambda: not a lambda" diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index f1df754803e..1fbc5338f49 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -278,6 +278,8 @@ let [] localOptDefault = true let [] crossModuleOptDefault = true +let [] LambdaInlineThresholdDefault = 6 + type OptimizationSettings = { abstractBigTargets : bool @@ -315,7 +317,7 @@ type OptimizationSettings = bigTargetSize = 100 veryBigExprSize = 3000 crossModuleOptUser = None - lambdaInlineThreshold = 6 + lambdaInlineThreshold = LambdaInlineThresholdDefault reportingPhase = false reportNoNeedToTailcall = false reportFunctionSizes = false @@ -419,6 +421,14 @@ type IncrementalOptimizationEnv = override x.ToString() = "" +let SetAbstractBigTargetsOn cenv = + { cenv with + settings = + { cenv.settings with + abstractBigTargets = true + } + } + //------------------------------------------------------------------------- // IsPartialExprVal - is the expr fully known? //------------------------------------------------------------------------- @@ -2911,6 +2921,15 @@ and OptimizeLambdas (vspec: Val option) cenv env topValInfo e ety = let env = Option.foldBack (BindInternalValToUnknown cenv) baseValOpt env let env = BindTypeVarsToUnknown tps env let env = List.foldBack (BindInternalValsToUnknown cenv) vsl env + + let cenv = + match env.functionVal with + // If the lambda is compiler generated and we are in the reporing phase, allow lambda to be split. + // As an example, allows generated GetHashCode/Equals/CompareTo/etc methods to be split even if optimizations were off. + // This helps prevent stack overflows in IlxGen.fs. + | Some (v, _) when v.IsCompilerGenerated && cenv.settings.reportingPhase -> SetAbstractBigTargetsOn cenv + | _ -> cenv + let env = BindInternalValsToUnknown cenv (Option.toList baseValOpt) env let bodyR, bodyinfo = OptimizeExpr cenv env body let exprR = mkMemberLambdas m tps ctorThisValOpt baseValOpt vsl (bodyR, bodyty) diff --git a/src/fsharp/Optimizer.fsi b/src/fsharp/Optimizer.fsi index e156a26d3ea..d489878da1a 100644 --- a/src/fsharp/Optimizer.fsi +++ b/src/fsharp/Optimizer.fsi @@ -62,3 +62,7 @@ val UnionOptimizationInfos: seq -> CcuOptimizationInfo val ExprHasEffect: TcGlobals -> Expr -> bool val internal u_CcuOptimizationInfo : TastPickle.ReaderState -> CcuOptimizationInfo + +// REVIEW: We need to put the literal at the end of a file due to a bug that causes a compiler error when a literal is put in the middle other signature constructs. +[] +val LambdaInlineThresholdDefault : int = 6 \ No newline at end of file From 4df0e4fdd8703bc73b352a6fb699865650de6208 Mon Sep 17 00:00:00 2001 From: TIHan Date: Mon, 28 Oct 2019 13:33:57 -0700 Subject: [PATCH 06/68] fix regression test, starting to add linear match expr handling --- src/fsharp/IlxGen.fs | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 857365a6fca..8015d3ef1cb 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -1913,8 +1913,7 @@ let CodeGenThen cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, c (* Call the given code generator *) codeGenFunction cgbuf { eenv with withinSEH = false liveLocals = IntMap.empty() - innerVals = innerVals - inLoop = false } + innerVals = innerVals } let locals, maxStack, lab2pc, code, exnSpecs, hasSequencePoints = cgbuf.Close() @@ -2212,6 +2211,15 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = | None -> match expr with + // Most generation of linear expressions is implemented routinely using tailcalls and the correct sequels. + // This is because the element of expansion happens to be the final thing generated in most cases. However + // for large lists we have to process the linearity separately + | Expr.Sequential _ + | Expr.Let _ + | LinearOpExpr _ + | LinearMatchExpr _ -> + GenLinearExpr cenv cgbuf eenv sp expr sequel (* canProcessSequencePoint *) false id |> ignore + | Expr.Const (c, m, ty) -> GenConstant cenv cgbuf eenv (c, m, ty) sequel | Expr.Match (spBind, exprm, tree, targets, m, ty) -> @@ -2235,14 +2243,6 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = | Expr.Val (v, _, m) -> GenGetVal cenv cgbuf eenv (v, m) sequel - // Most generation of linear expressions is implemented routinely using tailcalls and the correct sequels. - // This is because the element of expansion happens to be the final thing generated in most cases. However - // for large lists we have to process the linearity separately - | Expr.Sequential _ - | Expr.Let _ - | LinearOpExpr _ -> - GenLinearExpr cenv cgbuf eenv sp expr sequel (* canProcessSequencePoint *) false id |> ignore - | Expr.Op (op, tyargs, args, m) -> match op, args, tyargs with | TOp.ExnConstr c, _, _ -> @@ -2555,6 +2555,10 @@ and GenAllocUnionCase cenv cgbuf eenv (c,tyargs,args,m) sequel = and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) = let expr = stripExpr expr + + if canProcessSequencePoint then + ProcessSequencePointForExpr cenv cgbuf sp expr + match expr with | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> GenExprs cenv cgbuf eenv argsFront @@ -2564,9 +2568,6 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: Fake)) | Expr.Sequential (e1, e2, specialSeqFlag, spSeq, _) -> - if canProcessSequencePoint then - ProcessSequencePointForExpr cenv cgbuf sp expr - // Compiler generated sequential executions result in suppressions of sequence points on both // left and right of the sequence let spAction, spExpr = @@ -2585,9 +2586,6 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: contf Fake | Expr.Let (bind, body, _, _) -> - if canProcessSequencePoint then - ProcessSequencePointForExpr cenv cgbuf sp expr - // This case implemented here to get a guaranteed tailcall // Make sure we generate the sequence point outside the scope of the variable let startScope, endScope as scopeMarks = StartDelayedLocalScope "let" cgbuf @@ -2609,6 +2607,11 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // Generate the body GenLinearExpr cenv cgbuf eenv spBody body (EndLocalScope(sequel, endScope)) (* canProcessSequencePoint *) true contf + | LinearMatchExpr (spBind, exprm, tree, tg1, e2, spTg2, m, ty) -> + GenMatch cenv cgbuf eenv (spBind, exprm, tree, [|tg1;TTarget([], e2, spTg2)|], m, ty) sequel + contf Fake + //| Expr.Match (spBind, exprm, tree, targets, m, ty) -> + // GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel | _ -> GenExpr cenv cgbuf eenv sp expr sequel contf Fake From bf043555cc2fbdc46c270122de5122af132f9ccc Mon Sep 17 00:00:00 2001 From: TIHan Date: Mon, 28 Oct 2019 15:03:35 -0700 Subject: [PATCH 07/68] Minor code move --- src/fsharp/IlxGen.fs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 8015d3ef1cb..fa3dc689627 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2560,13 +2560,6 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: ProcessSequencePointForExpr cenv cgbuf sp expr match expr with - | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> - GenExprs cenv cgbuf eenv argsFront - GenLinearExpr cenv cgbuf eenv SPSuppress argLast Continue (* canProcessSequencePoint *) true (contf << (fun Fake -> - GenAllocUnionCaseCore cenv cgbuf eenv (c, tyargs, argsFront.Length + 1, m) - GenSequel cenv eenv.cloc cgbuf sequel - Fake)) - | Expr.Sequential (e1, e2, specialSeqFlag, spSeq, _) -> // Compiler generated sequential executions result in suppressions of sequence points on both // left and right of the sequence @@ -2610,8 +2603,14 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: | LinearMatchExpr (spBind, exprm, tree, tg1, e2, spTg2, m, ty) -> GenMatch cenv cgbuf eenv (spBind, exprm, tree, [|tg1;TTarget([], e2, spTg2)|], m, ty) sequel contf Fake - //| Expr.Match (spBind, exprm, tree, targets, m, ty) -> - // GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel + + | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> + GenExprs cenv cgbuf eenv argsFront + GenLinearExpr cenv cgbuf eenv SPSuppress argLast Continue (* canProcessSequencePoint *) true (contf << (fun Fake -> + GenAllocUnionCaseCore cenv cgbuf eenv (c, tyargs, argsFront.Length + 1, m) + GenSequel cenv eenv.cloc cgbuf sequel + Fake)) + | _ -> GenExpr cenv cgbuf eenv sp expr sequel contf Fake @@ -4376,7 +4375,10 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr | Some v -> [(v, BranchCallClosure (cloinfo.cloArityInfo))] | _ -> [] - DelayGenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) + if cenv.exprRecursionDepth > 0 then + DelayGenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) + else + GenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) cloinfo, m | _ -> failwith "GenLambda: not a lambda" From 99a2ca25dcb3ef1f3c93e523b04a600d563a89ea Mon Sep 17 00:00:00 2001 From: TIHan Date: Tue, 29 Oct 2019 17:54:57 -0700 Subject: [PATCH 08/68] Might have it working --- src/fsharp/IlxGen.fs | 270 +++++++++++++++--------- tests/fsharp/Compiler/CompilerAssert.fs | 2 +- 2 files changed, 172 insertions(+), 100 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index fa3dc689627..a4e170fe6cb 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2217,13 +2217,13 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = | Expr.Sequential _ | Expr.Let _ | LinearOpExpr _ - | LinearMatchExpr _ -> + | Expr.Match _ -> GenLinearExpr cenv cgbuf eenv sp expr sequel (* canProcessSequencePoint *) false id |> ignore | Expr.Const (c, m, ty) -> GenConstant cenv cgbuf eenv (c, m, ty) sequel - | Expr.Match (spBind, exprm, tree, targets, m, ty) -> - GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel + //| Expr.Match (spBind, exprm, tree, targets, m, ty) -> + // GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel | Expr.LetRec (binds, body, m, _) -> GenLetRec cenv cgbuf eenv (binds, body, m) sequel | Expr.Lambda _ | Expr.TyLambda _ -> @@ -2553,14 +2553,34 @@ and GenAllocUnionCase cenv cgbuf eenv (c,tyargs,args,m) sequel = GenAllocUnionCaseCore cenv cgbuf eenv (c,tyargs,args.Length,m) GenSequel cenv eenv.cloc cgbuf sequel -and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) = - let expr = stripExpr expr +and GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin = + CG.SetMarkToHere cgbuf afterJoin + + //assert(cgbuf.GetCurrentStack() = stackAfterJoin) // REVIEW: Since gen_dtree* now sets stack, stack should be stackAfterJoin at this point... + CG.SetStack cgbuf stackAfterJoin + // If any values are left on the stack after the join then we're certainly going to do something with them + // For example, we may be about to execute a 'stloc' for + // + // let y2 = if System.DateTime.Now.Year < 2000 then 1 else 2 + // + // or a 'stelem' for + // + // arr.[0] <- if System.DateTime.Now.Year > 2000 then 1 else 2 + // + // In both cases, any instructions that come after this point will be falsely associated with the last branch of the control + // prior to the join point. This is base, e.g. see FSharp 1.0 bug 5155 + if not (isNil stackAfterJoin) then + cgbuf.EmitStartOfHiddenCode() - if canProcessSequencePoint then - ProcessSequencePointForExpr cenv cgbuf sp expr + GenSequel cenv eenv.cloc cgbuf sequelAfterJoin +and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) = + let expr = stripExpr expr match expr with | Expr.Sequential (e1, e2, specialSeqFlag, spSeq, _) -> + if canProcessSequencePoint then + ProcessSequencePointForExpr cenv cgbuf sp expr + // Compiler generated sequential executions result in suppressions of sequence points on both // left and right of the sequence let spAction, spExpr = @@ -2579,6 +2599,9 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: contf Fake | Expr.Let (bind, body, _, _) -> + if canProcessSequencePoint then + ProcessSequencePointForExpr cenv cgbuf sp expr + // This case implemented here to get a guaranteed tailcall // Make sure we generate the sequence point outside the scope of the variable let startScope, endScope as scopeMarks = StartDelayedLocalScope "let" cgbuf @@ -2600,11 +2623,80 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // Generate the body GenLinearExpr cenv cgbuf eenv spBody body (EndLocalScope(sequel, endScope)) (* canProcessSequencePoint *) true contf - | LinearMatchExpr (spBind, exprm, tree, tg1, e2, spTg2, m, ty) -> - GenMatch cenv cgbuf eenv (spBind, exprm, tree, [|tg1;TTarget([], e2, spTg2)|], m, ty) sequel - contf Fake + | Expr.Match (spBind, _exprm, tree, targets, m, ty) -> + if canProcessSequencePoint then + ProcessSequencePointForExpr cenv cgbuf sp expr + + match spBind with + | SequencePointAtBinding m -> CG.EmitSeqPoint cgbuf m + | NoSequencePointAtDoBinding + | NoSequencePointAtLetBinding + | NoSequencePointAtInvisibleBinding + | NoSequencePointAtStickyBinding -> () + + // The target of branch needs a sequence point. + // If we don't give it one it will get entirely the wrong sequence point depending on earlier codegen + // Note we're not interested in having pattern matching and decision trees reveal their inner working. + // Hence at each branch target we 'reassert' the overall sequence point that was active as we came into the match. + // + // NOTE: sadly this causes multiple sequence points to appear for the "initial" location of an if/then/else or match. + let activeSP = cgbuf.GetLastSequencePoint() + let repeatSP() = + match activeSP with + | None -> () + | Some src -> + if activeSP <> cgbuf.GetLastSequencePoint() then + CG.EmitSeqPoint cgbuf src + + // First try the common cases where we don't need a join point. + match tree with + | TDSuccess _ -> + failwith "internal error: matches that immediately succeed should have been normalized using mkAndSimplifyMatch" + + | _ -> + // Create a join point + let stackAtTargets = cgbuf.GetCurrentStack() // the stack at the target of each clause + let (sequelOnBranches, afterJoin, stackAfterJoin, sequelAfterJoin) = GenJoinPoint cenv cgbuf "match" eenv ty m sequel + + // Stack: "stackAtTargets" is "stack prior to any match-testing" and also "stack at the start of each branch-RHS". + // match-testing (dtrees) should not contribute to the stack. + // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. + // Since code is branching and joining, the cgbuf stack is maintained manually. + let genTargetInfo, targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches + if genTargetInfo.contents.IsSome then + let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value + + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget (* canProcessSequencePoint *) true (contf << (fun Fake -> + if targetQueue.Count > 0 then + targetQueue.Dequeue()() + + if genTargetInfo.contents.IsSome then + let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value + + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget (* canProcessSequencePoint *) true (contf << (fun Fake -> + if targetQueue.Count > 0 then + targetQueue.Dequeue()() + + while genTargetInfo.contents.IsSome do + let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value + GenExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget + if targetQueue.Count > 0 then + targetQueue.Dequeue()() + + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + Fake)) + else + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + Fake + )) + else + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + contf Fake | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> + if canProcessSequencePoint then + ProcessSequencePointForExpr cenv cgbuf sp expr + GenExprs cenv cgbuf eenv argsFront GenLinearExpr cenv cgbuf eenv SPSuppress argLast Continue (* canProcessSequencePoint *) true (contf << (fun Fake -> GenAllocUnionCaseCore cenv cgbuf eenv (c, tyargs, argsFront.Length + 1, m) @@ -4788,69 +4880,45 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = let afterJoin = CG.GenerateDelayMark cgbuf (pos + "_join") // go to the join point Br afterJoin, afterJoin, stackAfterJoin, sequel - -and GenMatch cenv cgbuf eenv (spBind, _exprm, tree, targets, m, ty) sequel = - - match spBind with - | SequencePointAtBinding m -> CG.EmitSeqPoint cgbuf m - | NoSequencePointAtDoBinding - | NoSequencePointAtLetBinding - | NoSequencePointAtInvisibleBinding - | NoSequencePointAtStickyBinding -> () - - // The target of branch needs a sequence point. - // If we don't give it one it will get entirely the wrong sequence point depending on earlier codegen - // Note we're not interested in having pattern matching and decision trees reveal their inner working. - // Hence at each branch target we 'reassert' the overall sequence point that was active as we came into the match. - // - // NOTE: sadly this causes multiple sequence points to appear for the "initial" location of an if/then/else or match. - let activeSP = cgbuf.GetLastSequencePoint() - let repeatSP() = - match activeSP with - | None -> () - | Some src -> - if activeSP <> cgbuf.GetLastSequencePoint() then - CG.EmitSeqPoint cgbuf src - - // First try the common cases where we don't need a join point. - match tree with - | TDSuccess _ -> - failwith "internal error: matches that immediately succeed should have been normalized using mkAndSimplifyMatch" - - | _ -> - // Create a join point - let stackAtTargets = cgbuf.GetCurrentStack() // the stack at the target of each clause - let (sequelOnBranches, afterJoin, stackAfterJoin, sequelAfterJoin) = GenJoinPoint cenv cgbuf "match" eenv ty m sequel - - // Stack: "stackAtTargets" is "stack prior to any match-testing" and also "stack at the start of each branch-RHS". - // match-testing (dtrees) should not contribute to the stack. - // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. - // Since code is branching and joining, the cgbuf stack is maintained manually. - GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches - CG.SetMarkToHere cgbuf afterJoin - - //assert(cgbuf.GetCurrentStack() = stackAfterJoin) // REVIEW: Since gen_dtree* now sets stack, stack should be stackAfterJoin at this point... - CG.SetStack cgbuf stackAfterJoin - // If any values are left on the stack after the join then we're certainly going to do something with them - // For example, we may be about to execute a 'stloc' for - // - // let y2 = if System.DateTime.Now.Year < 2000 then 1 else 2 - // - // or a 'stelem' for - // - // arr.[0] <- if System.DateTime.Now.Year > 2000 then 1 else 2 - // - // In both cases, any instructions that come after this point will be falsely associated with the last branch of the control - // prior to the join point. This is base, e.g. see FSharp 1.0 bug 5155 - if not (isNil stackAfterJoin) then - cgbuf.EmitStartOfHiddenCode() - - GenSequel cenv eenv.cloc cgbuf sequelAfterJoin // Accumulate the decision graph as we go -and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel = - let targetInfos = GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv tree targets repeatSP (IntMap.empty()) sequel - GenPostponedDecisionTreeTargets cenv cgbuf stackAtTargets targetInfos sequel +and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Ref<(IlxGenEnv * EmitSequencePointState * Expr * sequel) option> * Queue unit>) = + let rec genDecisions targetInfos decisions (genTargetInfo: ref<_>) (queue: Queue<_>) = + match decisions with + | [] -> + let remaining = + targetInfos + |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) + |> Seq.filter (fun (KeyValue(_, (_, isTargetPostponed))) -> isTargetPostponed) + |> List.ofSeq + + let rec genRemaining remaining (genTargetInfo: ref<_>) (queue: Queue<_>) = + match remaining with + | [] -> genTargetInfo := None + | (KeyValue(targetIdx, (targetInfo, _))) :: rest -> + genTargetInfo := Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) + queue.Enqueue(fun () -> genRemaining rest genTargetInfo queue) + + genRemaining remaining genTargetInfo queue + + | (inplabOpt, tree) :: rest -> + match tree with + | TDSuccess(es, targetIdx) -> + let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel + match genTargetInfoOpt with + | Some _ -> + genTargetInfo := genTargetInfoOpt + queue.Enqueue(fun () -> genDecisions targetInfos rest genTargetInfo queue) + | _ -> + genDecisions targetInfos rest genTargetInfo queue + | _ -> + let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel + genDecisions targetInfos (newDecisions @ rest) genTargetInfo queue + + let res = ref None + let queue = Queue() + genDecisions (IntMap.empty()) [(None, tree)] res queue + res, queue and TryFindTargetInfo targetInfos n = match IntMap.tryFind n targetInfos with @@ -4861,7 +4929,7 @@ and TryFindTargetInfo targetInfos n = /// /// When inplabOpt is "Some inplab", we are assuming an existing branch to "inplab" and can optionally /// set inplab to point to another location if no codegen is required. -and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel = +and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel : (Mark option * DecisionTree) list = CG.SetStack cgbuf stackAtTargets // Set the expected initial stack. match tree with | TDBind(bind, rest) -> @@ -4876,8 +4944,9 @@ and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree CG.SetMarkToHere cgbuf endScope GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv rest targets repeatSP targetInfos sequel - | TDSuccess (es, targetIdx) -> - GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel + | TDSuccess (_es, _targetIdx) -> + [(inplabOpt, tree)] + //GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel | TDSwitch(e, cases, dflt, m) -> GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases dflt m targets repeatSP targetInfos sequel @@ -4908,7 +4977,7 @@ and GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx vs |> List.rev |> List.iter (fun v -> GenStoreVal cenv cgbuf eenvAtTarget v.Range v) CG.EmitInstr cgbuf (pop 0) Push0 (I_br targetMarkAfterBinds.CodeLabel) - targetInfos + targetInfos, None | None -> @@ -4921,22 +4990,21 @@ and GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx let targetInfo = (targetMarkBeforeBinds, targetMarkAfterBinds, eenvAtTarget, successExpr, spTarget, repeatSP, vs, binds, startScope, endScope) // In debug mode push all decision tree targets to after the switching - let isTargetPostponed = - if cenv.opts.localOptimizationsAreOn then - GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel - false + let isTargetPostponed, genTargetInfoOpt = + if cenv.opts.localOptimizationsAreOn then + false, Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) else CG.EmitInstr cgbuf (pop 0) Push0 (I_br targetMarkBeforeBinds.CodeLabel) - true + true, None let targetInfos = IntMap.add targetIdx (targetInfo, isTargetPostponed) targetInfos - targetInfos + targetInfos, genTargetInfoOpt -and GenPostponedDecisionTreeTargets cenv cgbuf stackAtTargets targetInfos sequel = - let targetInfos = targetInfos |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) - for (KeyValue(targetIdx, (targetInfo, isTargetPostponed))) in targetInfos do - if isTargetPostponed then - GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel +//and GenPostponedDecisionTreeTargets cenv cgbuf stackAtTargets targetInfos sequel : unit = +// let targetInfos = targetInfos |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) +// for (KeyValue(targetIdx, (targetInfo, isTargetPostponed))) in targetInfos do +// if isTargetPostponed then +// GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel and GenDecisionTreeTarget cenv cgbuf stackAtTargets _targetIdx (targetMarkBeforeBinds, targetMarkAfterBinds, eenvAtTarget, successExpr, spTarget, repeatSP, vs, binds, startScope, endScope) sequel = CG.SetMarkToHere cgbuf targetMarkBeforeBinds @@ -4959,10 +5027,11 @@ and GenDecisionTreeTarget cenv cgbuf stackAtTargets _targetIdx (targetMarkBefore GenBindings cenv cgbuf eenvAtTarget binds CG.SetMarkToHere cgbuf targetMarkAfterBinds CG.SetStack cgbuf stackAtTargets - GenExpr cenv cgbuf eenvAtTarget spExpr successExpr (EndLocalScope(sequel, endScope)) + (eenvAtTarget, spExpr, successExpr, (EndLocalScope(sequel, endScope))) + //GenExpr cenv cgbuf eenvAtTarget spExpr successExpr (EndLocalScope(sequel, endScope)) -and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel = +and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel : (Mark option * DecisionTree) list = let g = cenv.g let m = e.Range match inplabOpt with None -> () | Some inplab -> CG.SetMarkToHere cgbuf inplab @@ -5082,23 +5151,22 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel | _ -> error(InternalError("these matches should never be needed", switchm)) -and GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel = +and GenDecisionTreeCases _cenv cgbuf stackAtTargets _eenv _targets _repeatSP _targetInfos defaultTargetOpt caseLabels cases _sequel = assert(cgbuf.GetCurrentStack() = stackAtTargets) // cgbuf stack should be unchanged over tests. [bug://1750]. let targetInfos = match defaultTargetOpt with - | Some defaultTarget -> GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel - | None -> targetInfos + | Some defaultTarget -> [(None, defaultTarget)] //GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel + | None -> [] - let targetInfos = - (targetInfos, caseLabels, cases) |||> List.fold2 (fun targetInfos caseLabel (TCase(_, caseTree)) -> - GenDecisionTreeAndTargetsInner cenv cgbuf (Some caseLabel) stackAtTargets eenv caseTree targets repeatSP targetInfos sequel) - targetInfos + (targetInfos, caseLabels, cases) + |||> List.fold2 (fun targetInfos caseLabel (TCase(_, caseTree)) -> targetInfos @ [(Some caseLabel, caseTree)]) + //GenDecisionTreeAndTargetsInner cenv cgbuf (Some caseLabel) stackAtTargets eenv caseTree targets repeatSP targetInfos sequel) // Used for the peephole optimization below and (|BoolExpr|_|) = function Expr.Const (Const.Bool b1, _, _) -> Some b1 | _ -> None -and GenDecisionTreeTest cenv cloc cgbuf stackAtTargets e tester eenv successTree failureTree targets repeatSP targetInfos sequel = +and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTree failureTree targets _repeatSP _targetInfos sequel : (Mark option * DecisionTree) list = let g = cenv.g match successTree, failureTree with @@ -5125,7 +5193,7 @@ and GenDecisionTreeTest cenv cloc cgbuf stackAtTargets e tester eenv successTree CG.EmitInstrs cgbuf (pop 0) (Push [g.ilg.typ_Bool]) [mkLdcInt32 0 ] CG.EmitInstrs cgbuf (pop 1) Push0 [AI_ceq] GenSequel cenv cloc cgbuf sequel - targetInfos + [] | _ -> failwith "internal error: GenDecisionTreeTest during bool elim" @@ -5147,9 +5215,13 @@ and GenDecisionTreeTest cenv cloc cgbuf stackAtTargets e tester eenv successTree | Choice2Of2 i -> CG.EmitInstr cgbuf pops pushes i CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (BI_brfalse, failure.CodeLabel)) - let targetInfos = GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv successTree targets repeatSP targetInfos sequel + [ + (None, successTree) + (Some failure, failureTree) + ] + // let targetInfos = GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv successTree targets repeatSP targetInfos sequel - GenDecisionTreeAndTargetsInner cenv cgbuf (Some failure) stackAtTargets eenv failureTree targets repeatSP targetInfos sequel + // GenDecisionTreeAndTargetsInner cenv cgbuf (Some failure) stackAtTargets eenv failureTree targets repeatSP targetInfos sequel /// Generate fixups for letrec bindings and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFieldSpec, e2, _m) = diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index f4f5e008f00..50102ab21c4 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -143,7 +143,7 @@ let main argv = 0""" ProjectId = None SourceFiles = [|"test.fs"|] #if !NETCOREAPP - OtherOptions = [|"--preferreduilang:en-US";"--warn:5";"--optimize-"|] + OtherOptions = [|"--preferreduilang:en-US";"--warn:5"|] #else OtherOptions = let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x) From f3ab72cc06d2494daa0330ac764edb6d4b259d9a Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 14:17:36 -0700 Subject: [PATCH 09/68] Fixed issue not capturing locals --- src/fsharp/IlxGen.fs | 91 ++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 54 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index a4e170fe6cb..4eed15abc50 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2662,36 +2662,20 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // match-testing (dtrees) should not contribute to the stack. // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. // Since code is branching and joining, the cgbuf stack is maintained manually. - let genTargetInfo, targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches - if genTargetInfo.contents.IsSome then - let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value - - GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget (* canProcessSequencePoint *) true (contf << (fun Fake -> - if targetQueue.Count > 0 then - targetQueue.Dequeue()() - - if genTargetInfo.contents.IsSome then - let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value - - GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget (* canProcessSequencePoint *) true (contf << (fun Fake -> - if targetQueue.Count > 0 then - targetQueue.Dequeue()() - - while genTargetInfo.contents.IsSome do - let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = genTargetInfo.contents.Value - GenExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget - if targetQueue.Count > 0 then - targetQueue.Dequeue()() - - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - Fake)) - else - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - Fake - )) - else - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - contf Fake + let targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches + let rec processTarget (targetQueue: Queue<_>) = + if targetQueue.Count > 0 then + let f = targetQueue.Dequeue() + let genTargetInfoOpt = f () + match genTargetInfoOpt with + | Some(eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> + GenExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget + | _ -> + () + processTarget targetQueue + processTarget targetQueue + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + contf Fake | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> if canProcessSequencePoint then @@ -4882,8 +4866,8 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = Br afterJoin, afterJoin, stackAfterJoin, sequel // Accumulate the decision graph as we go -and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Ref<(IlxGenEnv * EmitSequencePointState * Expr * sequel) option> * Queue unit>) = - let rec genDecisions targetInfos decisions (genTargetInfo: ref<_>) (queue: Queue<_>) = +and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Queue (IlxGenEnv * EmitSequencePointState * Expr * sequel) option>) = + let rec genDecisions targetInfos decisions (queue: Queue<_>) = match decisions with | [] -> let remaining = @@ -4892,33 +4876,32 @@ and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeat |> Seq.filter (fun (KeyValue(_, (_, isTargetPostponed))) -> isTargetPostponed) |> List.ofSeq - let rec genRemaining remaining (genTargetInfo: ref<_>) (queue: Queue<_>) = + let rec genRemaining remaining (queue: Queue<_>) = match remaining with - | [] -> genTargetInfo := None + | [] -> None | (KeyValue(targetIdx, (targetInfo, _))) :: rest -> - genTargetInfo := Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) - queue.Enqueue(fun () -> genRemaining rest genTargetInfo queue) + queue.Enqueue(fun () -> genRemaining rest queue) + Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) - genRemaining remaining genTargetInfo queue + genRemaining remaining queue - | (inplabOpt, tree) :: rest -> + | (inplabOpt, eenv, tree) :: rest -> match tree with | TDSuccess(es, targetIdx) -> let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel match genTargetInfoOpt with | Some _ -> - genTargetInfo := genTargetInfoOpt - queue.Enqueue(fun () -> genDecisions targetInfos rest genTargetInfo queue) + queue.Enqueue(fun () -> genDecisions targetInfos rest queue) + genTargetInfoOpt | _ -> - genDecisions targetInfos rest genTargetInfo queue + genDecisions targetInfos rest queue | _ -> let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel - genDecisions targetInfos (newDecisions @ rest) genTargetInfo queue + genDecisions targetInfos (newDecisions @ rest) queue - let res = ref None let queue = Queue() - genDecisions (IntMap.empty()) [(None, tree)] res queue - res, queue + queue.Enqueue (fun () -> genDecisions (IntMap.empty()) [(None, eenv, tree)] queue) + queue and TryFindTargetInfo targetInfos n = match IntMap.tryFind n targetInfos with @@ -4929,7 +4912,7 @@ and TryFindTargetInfo targetInfos n = /// /// When inplabOpt is "Some inplab", we are assuming an existing branch to "inplab" and can optionally /// set inplab to point to another location if no codegen is required. -and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel : (Mark option * DecisionTree) list = +and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel = CG.SetStack cgbuf stackAtTargets // Set the expected initial stack. match tree with | TDBind(bind, rest) -> @@ -4945,7 +4928,7 @@ and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv rest targets repeatSP targetInfos sequel | TDSuccess (_es, _targetIdx) -> - [(inplabOpt, tree)] + [(inplabOpt, eenv, tree)] //GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel | TDSwitch(e, cases, dflt, m) -> @@ -5031,7 +5014,7 @@ and GenDecisionTreeTarget cenv cgbuf stackAtTargets _targetIdx (targetMarkBefore //GenExpr cenv cgbuf eenvAtTarget spExpr successExpr (EndLocalScope(sequel, endScope)) -and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel : (Mark option * DecisionTree) list = +and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel = let g = cenv.g let m = e.Range match inplabOpt with None -> () | Some inplab -> CG.SetMarkToHere cgbuf inplab @@ -5151,22 +5134,22 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel | _ -> error(InternalError("these matches should never be needed", switchm)) -and GenDecisionTreeCases _cenv cgbuf stackAtTargets _eenv _targets _repeatSP _targetInfos defaultTargetOpt caseLabels cases _sequel = +and GenDecisionTreeCases _cenv cgbuf stackAtTargets eenv _targets _repeatSP _targetInfos defaultTargetOpt caseLabels cases _sequel = assert(cgbuf.GetCurrentStack() = stackAtTargets) // cgbuf stack should be unchanged over tests. [bug://1750]. let targetInfos = match defaultTargetOpt with - | Some defaultTarget -> [(None, defaultTarget)] //GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel + | Some defaultTarget -> [(None, eenv, defaultTarget)] //GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel | None -> [] (targetInfos, caseLabels, cases) - |||> List.fold2 (fun targetInfos caseLabel (TCase(_, caseTree)) -> targetInfos @ [(Some caseLabel, caseTree)]) + |||> List.fold2 (fun targetInfos caseLabel (TCase(_, caseTree)) -> targetInfos @ [(Some caseLabel, eenv, caseTree)]) //GenDecisionTreeAndTargetsInner cenv cgbuf (Some caseLabel) stackAtTargets eenv caseTree targets repeatSP targetInfos sequel) // Used for the peephole optimization below and (|BoolExpr|_|) = function Expr.Const (Const.Bool b1, _, _) -> Some b1 | _ -> None -and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTree failureTree targets _repeatSP _targetInfos sequel : (Mark option * DecisionTree) list = +and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTree failureTree targets _repeatSP _targetInfos sequel = let g = cenv.g match successTree, failureTree with @@ -5216,8 +5199,8 @@ and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTre CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (BI_brfalse, failure.CodeLabel)) [ - (None, successTree) - (Some failure, failureTree) + (None, eenv, successTree) + (Some failure, eenv, failureTree) ] // let targetInfos = GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv successTree targets repeatSP targetInfos sequel From cdc391e4daeee4cd8dd469b08e72b14383e337b0 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Wed, 30 Oct 2019 15:26:33 -0700 Subject: [PATCH 10/68] update perl test runner (#7779) --- TESTGUIDE.md | 2 +- eng/Build.ps1 | 4 +++- eng/Versions.props | 2 +- tests/fsharp/FSharpSuite.Tests.fsproj | 3 +-- tests/fsharpqa/run.fsharpqa.test.fsx | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TESTGUIDE.md b/TESTGUIDE.md index ef34e6f51bb..f658b443c1d 100644 --- a/TESTGUIDE.md +++ b/TESTGUIDE.md @@ -46,7 +46,7 @@ There are also negative tests checking code expected to fail compilation. See no ### FSharpQA Suite -The FSharpQA suite relies on [Perl](http://www.perl.org/get.html), StrawberryPerl64 package from nuget is used automatically by the test suite. +The FSharpQA suite relies on [Perl](http://www.perl.org/get.html), StrawberryPerl package from nuget is used automatically by the test suite. These tests use the `RunAll.pl` framework to execute, however the easiest way to run them is via the `build.cmd` script, see [usage examples](https://github.com/Microsoft/visualfsharp/blob/master/build.cmd#L31). diff --git a/eng/Build.ps1 b/eng/Build.ps1 index 4d503dbedaa..f9d7e1b5ac7 100644 --- a/eng/Build.ps1 +++ b/eng/Build.ps1 @@ -359,7 +359,8 @@ try { $resultsLog = "test-net40-fsharpqa-results.log" $errorLog = "test-net40-fsharpqa-errors.log" $failLog = "test-net40-fsharpqa-errors" - $perlExe = "$env:USERPROFILE\.nuget\packages\StrawberryPerl64\5.22.2.1\Tools\perl\bin\perl.exe" + $perlPackageRoot = "$env:USERPROFILE\.nuget\packages\StrawberryPerl\5.28.0.1"; + $perlExe = "$perlPackageRoot\bin\perl.exe" Create-Directory $resultsRoot UpdatePath $env:HOSTED_COMPILER = 1 @@ -367,6 +368,7 @@ try { $env:FSCOREDLLPATH = "$ArtifactsDir\bin\fsc\$configuration\net472\FSharp.Core.dll" $env:LINK_EXE = "$RepoRoot\tests\fsharpqa\testenv\bin\link\link.exe" $env:OSARCH = $env:PROCESSOR_ARCHITECTURE + $env:PERL5LIB = "$perlPackageRoot\vendor\lib" Exec-Console $perlExe """$RepoRoot\tests\fsharpqa\testenv\bin\runall.pl"" -resultsroot ""$resultsRoot"" -results $resultsLog -log $errorLog -fail $failLog -cleanup:no -procs:$env:NUMBER_OF_PROCESSORS" Pop-Location } diff --git a/eng/Versions.props b/eng/Versions.props index 8efcedaa538..caa59fe65ea 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -182,7 +182,7 @@ 3.11.0 2.1.36 1.0.0-beta2-dev3 - 5.22.2.1 + 5.28.0.1 2.0.187 diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 66d44a523a3..7d9b70ebe62 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -65,7 +65,6 @@ - @@ -82,7 +81,7 @@ - + diff --git a/tests/fsharpqa/run.fsharpqa.test.fsx b/tests/fsharpqa/run.fsharpqa.test.fsx index a29a242625b..18a2e118b81 100644 --- a/tests/fsharpqa/run.fsharpqa.test.fsx +++ b/tests/fsharpqa/run.fsharpqa.test.fsx @@ -36,7 +36,7 @@ let runPerl arguments = use perlProcess = ProcessStartInfo( - FileName = Path.Combine(nugetCache, "StrawberryPerl64", "5.22.2.1", "Tools", "perl", "bin", "perl.exe"), + FileName = Path.Combine(nugetCache, "StrawberryPerl", "5.28.0.1", "bin", "perl.exe"), Arguments = (arguments |> Array.map(fun a -> @"""" + a + @"""") |> String.concat " "), WorkingDirectory = Path.Combine(rootFolder, "tests", "fsharpqa", "source"), RedirectStandardOutput = true, From 998493780a86460df157967351776aeafe39c677 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Wed, 30 Oct 2019 15:29:02 -0700 Subject: [PATCH 11/68] Voption tostring and other stuff (#7712) * Fix some issues in ValueNone implementation * More debug display * Some for options in debug display * Apply suggestions from code review Co-Authored-By: Eugene Auduchinok * Probably better stringing * Add them baselines * Add sprintfn tests * Update OptionModule.fs --- src/fsharp/FSharp.Core/prim-types.fs | 25 +++++++++++++------ src/fsharp/FSharp.Core/prim-types.fsi | 5 ++++ .../Microsoft.FSharp.Core/OptionModule.fs | 12 ++++++++- .../SurfaceArea.coreclr.fs | 1 + .../SurfaceArea.net40.fs | 1 + 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/fsharp/FSharp.Core/prim-types.fs b/src/fsharp/FSharp.Core/prim-types.fs index 542852e5da9..664e1d4c02a 100644 --- a/src/fsharp/FSharp.Core/prim-types.fs +++ b/src/fsharp/FSharp.Core/prim-types.fs @@ -2883,7 +2883,7 @@ namespace Microsoft.FSharp.Core //------------------------------------------------------------------------- [] - [] + [] [] [] [] @@ -2907,6 +2907,11 @@ namespace Microsoft.FSharp.Core static member Some (value) : 'T option = Some(value) static member op_Implicit (value) : 'T option = Some(value) + + member private x.DebugDisplay = + match x with + | None -> "None" + | Some _ -> String.Format("Some({0})", anyToStringShowingNull x.Value) override x.ToString() = // x is non-null, hence Some @@ -2924,7 +2929,7 @@ namespace Microsoft.FSharp.Core [] [] [] - [] + [] type ValueOption<'T> = | ValueNone : 'T voption | ValueSome : 'T -> 'T voption @@ -2942,11 +2947,17 @@ namespace Microsoft.FSharp.Core [] member x.IsSome = match x with ValueSome _ -> true | _ -> false - static member op_Implicit (value) : 'T option = Some(value) - - override x.ToString() = - // x is non-null, hence ValueSome - "ValueSome("^anyToStringShowingNull x.Value^")" + static member op_Implicit (value) : 'T voption = ValueSome(value) + + member private x.DebugDisplay = + match x with + | ValueNone -> "ValueNone" + | ValueSome _ -> String.Format("ValueSome({0})", anyToStringShowingNull x.Value) + + override x.ToString() = + match x with + | ValueNone -> "ValueNone" + | ValueSome _ -> anyToStringShowingNull x.Value and 'T voption = ValueOption<'T> diff --git a/src/fsharp/FSharp.Core/prim-types.fsi b/src/fsharp/FSharp.Core/prim-types.fsi index 7ba3b3ae4d4..cd28701e67e 100644 --- a/src/fsharp/FSharp.Core/prim-types.fsi +++ b/src/fsharp/FSharp.Core/prim-types.fsi @@ -1860,6 +1860,11 @@ namespace Microsoft.FSharp.Core /// Return 'true' if the value option is a 'ValueNone' value. member IsNone : bool + + /// Implicitly converts a value into an optional that is a 'ValueSome' value. + /// The input value + /// A voption representing the value. + static member op_Implicit: value: 'T -> 'T voption /// The type of optional values, represented as structs. /// diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/OptionModule.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/OptionModule.fs index 3fb4395cd69..eaebc3df744 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/OptionModule.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Core/OptionModule.fs @@ -222,6 +222,16 @@ type ValueOptionTests() = let assertWasNotCalledThunk () = raise (exn "Thunk should not have been called.") + [] + member _.``ValueNone gives "ValueNone" when calling ToString`` () = + Assert.AreEqual("ValueNone", ValueNone.ToString()) + Assert.AreEqual("ValueNone", string ValueNone) + + [] + member _.``ValueNone with sprintf`` () = + Assert.AreEqual("ValueNone", sprintf "%O" (ValueNone.ToString())) + Assert.AreEqual("ValueNone", sprintf "%A" ValueNone) + [] member this.ValueOptionBasics () = Assert.AreEqual((ValueNone: int voption), (ValueNone: int voption)) @@ -444,4 +454,4 @@ type ValueOptionTests() = member this.MapBindEquivalenceProperties () = let fn x = x + 3 Assert.AreEqual(ValueOption.map fn ValueNone, ValueOption.bind (fn >> ValueSome) ValueNone) - Assert.AreEqual(ValueOption.map fn (ValueSome 5), ValueOption.bind (fn >> ValueSome) (ValueSome 5)) \ No newline at end of file + Assert.AreEqual(ValueOption.map fn (ValueSome 5), ValueOption.bind (fn >> ValueSome) (ValueSome 5)) diff --git a/tests/FSharp.Core.UnitTests/SurfaceArea.coreclr.fs b/tests/FSharp.Core.UnitTests/SurfaceArea.coreclr.fs index 561871089f0..7e3d81efd29 100644 --- a/tests/FSharp.Core.UnitTests/SurfaceArea.coreclr.fs +++ b/tests/FSharp.Core.UnitTests/SurfaceArea.coreclr.fs @@ -1746,6 +1746,7 @@ Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueO Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] ValueNone Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] get_None() Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] get_ValueNone() +Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] op_Implicit(T) Microsoft.FSharp.Core.FSharpValueOption`1[T]: System.String ToString() Microsoft.FSharp.Core.FSharpValueOption`1[T]: T Item Microsoft.FSharp.Core.FSharpValueOption`1[T]: T Value diff --git a/tests/FSharp.Core.UnitTests/SurfaceArea.net40.fs b/tests/FSharp.Core.UnitTests/SurfaceArea.net40.fs index 7a6f7f9d334..8499ecc0eba 100644 --- a/tests/FSharp.Core.UnitTests/SurfaceArea.net40.fs +++ b/tests/FSharp.Core.UnitTests/SurfaceArea.net40.fs @@ -1746,6 +1746,7 @@ Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueO Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] ValueNone Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] get_None() Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] get_ValueNone() +Microsoft.FSharp.Core.FSharpValueOption`1[T]: Microsoft.FSharp.Core.FSharpValueOption`1[T] op_Implicit(T) Microsoft.FSharp.Core.FSharpValueOption`1[T]: System.String ToString() Microsoft.FSharp.Core.FSharpValueOption`1[T]: T Item Microsoft.FSharp.Core.FSharpValueOption`1[T]: T Value From 515e15e0cb9e9ca7cc20447cfcabc226a70f1f04 Mon Sep 17 00:00:00 2001 From: Goswin Date: Wed, 30 Oct 2019 23:30:21 +0100 Subject: [PATCH 12/68] Optimize Seq.Last to behave like Seq.Length (incl. tests) (#7765) * Optimize Seq.Last like Seq.Length Add type check to Seq.Last and Seq.TryLast to avoid full iteration if not necessary. Like Seq.Length does it at https://github.com/dotnet/fsharp/blob/c18e1780b3f3f345364cb1ad8e510ea9f4590d3a/src/fsharp/FSharp.Core/seq.fs#L709 * Add test for Optimized Seq.Last and Seq.TryLast * style update * style update 2 * update comments and fix build error Github Build error was: Check failure on line 132 in tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\SeqModule2.fs @azure-pipelines azure-pipelines / fsharp-ci (Build Windows vs_release) tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\SeqModule2.fs#L132 tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\SeqModule2.fs(132,58): error FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'a has been constrained to be type 'unit'. * include List.last case * include list in tests * ensure same exception is raised on empty list * typo * Added implementation of List.last since it is not available at this point due to compilation error The recursive function could also be defined inside but i guess then it would be reallocated on every call to Seq.Last (in case of list match). An alternative would be to add .Last member on list type (like .Length member) * inline List.last reverting my previous attempt https://github.com/dotnet/fsharp/pull/7765/commits/b329e23c543b41b36143fafc77187acc58585471 tail rec functions should be inlined * typo in tests(build failed) * typo2 in test (Build failed) * move implemnetation to internal module as suggested by dsyme * renamed internal tryLast to tryLastV --- src/fsharp/FSharp.Core/list.fs | 17 ++- src/fsharp/FSharp.Core/local.fs | 29 +++++ src/fsharp/FSharp.Core/local.fsi | 4 + src/fsharp/FSharp.Core/seq.fs | 26 ++--- .../SeqModule2.fs | 107 +++++++++++++++++- 5 files changed, 156 insertions(+), 27 deletions(-) diff --git a/src/fsharp/FSharp.Core/list.fs b/src/fsharp/FSharp.Core/list.fs index e7fd17ee52d..87035fb3c66 100644 --- a/src/fsharp/FSharp.Core/list.fs +++ b/src/fsharp/FSharp.Core/list.fs @@ -9,6 +9,7 @@ namespace Microsoft.FSharp.Collections open Microsoft.FSharp.Collections open Microsoft.FSharp.Core.CompilerServices open System.Collections.Generic + [] [] @@ -24,18 +25,16 @@ namespace Microsoft.FSharp.Collections let length (list: 'T list) = list.Length [] - let rec last (list: 'T list) = - match list with - | [x] -> x - | _ :: tail -> last tail - | [] -> invalidArg "list" (SR.GetString(SR.inputListWasEmpty)) + let last (list: 'T list) = + match Microsoft.FSharp.Primitives.Basics.List.tryLastV list with + | ValueSome x -> x + | ValueNone -> invalidArg "list" (SR.GetString(SR.inputListWasEmpty)) [] let rec tryLast (list: 'T list) = - match list with - | [x] -> Some x - | _ :: tail -> tryLast tail - | [] -> None + match Microsoft.FSharp.Primitives.Basics.List.tryLastV list with + | ValueSome x -> Some x + | ValueNone -> None [] let rev list = Microsoft.FSharp.Primitives.Basics.List.rev list diff --git a/src/fsharp/FSharp.Core/local.fs b/src/fsharp/FSharp.Core/local.fs index 75dc2bb0908..0e97166352d 100644 --- a/src/fsharp/FSharp.Core/local.fs +++ b/src/fsharp/FSharp.Core/local.fs @@ -988,6 +988,12 @@ module internal List = takeWhileFreshConsTail cons p xs cons + let rec tryLastV (list: 'T list) = + match list with + | [] -> ValueNone + | [x] -> ValueSome x + | _ :: tail -> tryLastV tail + module internal Array = open System @@ -1187,3 +1193,26 @@ module internal Array = res.[i] <- subUnchecked !startIndex minChunkSize array startIndex := !startIndex + minChunkSize res + +module internal Seq = + let tryLastV (source : seq<_>) = + //checkNonNull "source" source //done in main Seq.tryLast + match source with + | :? ('T[]) as a -> + if a.Length = 0 then ValueNone + else ValueSome(a.[a.Length - 1]) + + | :? ('T IList) as a -> //ResizeArray and other collections + if a.Count = 0 then ValueNone + else ValueSome(a.[a.Count - 1]) + + | :? ('T list) as a -> List.tryLastV a + + | _ -> + use e = source.GetEnumerator() + if e.MoveNext() then + let mutable res = e.Current + while (e.MoveNext()) do res <- e.Current + ValueSome(res) + else + ValueNone \ No newline at end of file diff --git a/src/fsharp/FSharp.Core/local.fsi b/src/fsharp/FSharp.Core/local.fsi index 3181dcbc6ec..b5bcec9e955 100644 --- a/src/fsharp/FSharp.Core/local.fsi +++ b/src/fsharp/FSharp.Core/local.fsi @@ -65,6 +65,7 @@ module internal List = val splitAt : int -> 'T list -> ('T list * 'T list) val transpose : 'T list list -> 'T list list val truncate : int -> 'T list -> 'T list + val tryLastV : 'T list -> 'T ValueOption module internal Array = // The input parameter should be checked by callers if necessary @@ -101,3 +102,6 @@ module internal Array = val stableSortInPlaceWith: comparer:('T -> 'T -> int) -> array:'T[] -> unit val stableSortInPlace: array:'T[] -> unit when 'T : comparison + +module internal Seq = + val tryLastV : 'T seq -> 'T ValueOption diff --git a/src/fsharp/FSharp.Core/seq.fs b/src/fsharp/FSharp.Core/seq.fs index 97326e7315a..0b6e7ed2e5d 100644 --- a/src/fsharp/FSharp.Core/seq.fs +++ b/src/fsharp/FSharp.Core/seq.fs @@ -1377,29 +1377,21 @@ namespace Microsoft.FSharp.Collections invalidArg "source" (SR.GetString(SR.notEnoughElements)) while e.MoveNext() do yield e.Current } - + [] let last (source : seq<_>) = checkNonNull "source" source - use e = source.GetEnumerator() - if e.MoveNext() then - let mutable res = e.Current - while (e.MoveNext()) do res <- e.Current - res - else - invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString - + match Microsoft.FSharp.Primitives.Basics.Seq.tryLastV source with + | ValueSome x -> x + | ValueNone -> invalidArg "source" LanguagePrimitives.ErrorStrings.InputSequenceEmptyString + [] let tryLast (source : seq<_>) = checkNonNull "source" source - use e = source.GetEnumerator() - if e.MoveNext() then - let mutable res = e.Current - while (e.MoveNext()) do res <- e.Current - Some res - else - None - + match Microsoft.FSharp.Primitives.Basics.Seq.tryLastV source with + | ValueSome x -> Some x + | ValueNone -> None + [] let exactlyOne (source : seq<_>) = checkNonNull "source" source diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs index 700e4582934..289062f8a10 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Collections/SeqModule2.fs @@ -99,7 +99,57 @@ type SeqModule2() = // null Seq let nullSeq:seq<'a> = null CheckThrowsArgumentNullException (fun () ->Seq.last nullSeq) + + + // ------ Test for Array ----- + let IntArr = Array.ofSeq IntSeq + if Seq.last IntArr <> 9 then Assert.Fail() + + // string Array + let strArr = Array.ofSeq strSeq + if Seq.last strArr <> "third" then Assert.Fail() + + // Empty Array + let emptyArr = [| |] + CheckThrowsArgumentException ( fun() -> Seq.last emptyArr) + + // null Array + let nullArr: array<'a> = null + CheckThrowsArgumentNullException (fun () ->Seq.last nullArr) + + // ---- Test for IList ----- + let IntRarr = ResizeArray(IntSeq) + if Seq.last IntRarr <> 9 then Assert.Fail() + + // string IList + let strRarr = ResizeArray(strSeq) + if Seq.last strRarr <> "third" then Assert.Fail() + + // Empty IList + let emptyRarr = ResizeArray() + CheckThrowsArgumentException ( fun() -> Seq.last emptyRarr) + + // null IList + let nullRarr: ResizeArray = null + CheckThrowsArgumentNullException (fun () ->Seq.last nullRarr) + + // ---- Test for list ----- + let Intlist = List.ofSeq(IntSeq) + if Seq.last Intlist <> 9 then Assert.Fail() + + // string list + let strlist = List.ofSeq(strSeq) + if Seq.last strlist <> "third" then Assert.Fail() + + // Empty list + let emptylist: list = [] + CheckThrowsArgumentException ( fun() -> Seq.last emptylist) + + // null list + let nullList: list = Unchecked.defaultof> + CheckThrowsArgumentNullException (fun () ->Seq.last nullList) () + [] member this.TryLast() = @@ -120,8 +170,63 @@ type SeqModule2() = // null Seq let nullSeq:seq<'a> = null - CheckThrowsArgumentNullException (fun () ->Seq.tryLast nullSeq |> ignore) + CheckThrowsArgumentNullException (fun () ->Seq.tryLast nullSeq |> ignore) + + // ------ Test for Array ----- + let IntArr = Array.ofSeq IntSeq + let intResult = Seq.tryLast IntArr + Assert.AreEqual(9, intResult.Value) + + // string Array + let strResult = Seq.tryLast (Array.ofSeq (["first"; "second"; "third"])) + Assert.AreEqual("third", strResult.Value) + + // Empty Array + let emptyResult = Seq.tryLast Array.empty + Assert.IsTrue(emptyResult.IsNone) + + // null Array + let nullArr:array = null + CheckThrowsArgumentNullException (fun () -> Seq.tryLast nullArr |> ignore) + + + // ------ Test for IList ----- + let IntRarr = ResizeArray( IntSeq ) + let intResult = Seq.tryLast IntRarr + Assert.AreEqual(9, intResult.Value) + + // string IList + let strResult = Seq.tryLast (ResizeArray (["first"; "second"; "third"])) + Assert.AreEqual("third", strResult.Value) + + // Empty IList + let emptyResult = Seq.tryLast (ResizeArray()) + Assert.IsTrue(emptyResult.IsNone) + + // null IList + let nullRarr:ResizeArray = null + CheckThrowsArgumentNullException (fun () ->Seq.tryLast nullRarr |> ignore) + + // ------ Test for list ----- + let Intlist= List.ofSeq( IntSeq ) + let intResult = Seq.tryLast Intlist + Assert.AreEqual(9, intResult.Value) + + // string list + let strResult = Seq.tryLast ["first"; "second"; "third"] + Assert.AreEqual("third", strResult.Value) + + // Empty list + let emptylist: list = [] + let emptyResult = Seq.tryLast emptylist + Assert.IsTrue(emptyResult.IsNone) + + // null list + let nullList: list = Unchecked.defaultof> + CheckThrowsArgumentNullException (fun () ->Seq.tryLast nullList |> ignore) () + + [] member this.ExactlyOne() = From 9be86c23a9540c41929ff3dbcd904d069ba34a34 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Thu, 31 Oct 2019 02:29:02 +0300 Subject: [PATCH 13/68] Fix some typos (#7665) --- fcs/FSharp.Compiler.Service.sln.DotSettings | 780 ++++++++++++++++++ src/absil/bytes.fs | 6 +- src/absil/il.fs | 4 +- src/absil/ilascii.fs | 2 +- src/absil/illib.fs | 10 +- src/absil/ilmorph.fs | 2 +- src/absil/ilreflect.fs | 8 +- src/absil/ilsupp.fs | 22 +- src/absil/ilwrite.fs | 42 +- src/fsharp/CompileOps.fs | 68 +- src/fsharp/CompileOps.fsi | 2 +- src/fsharp/CompileOptions.fs | 4 +- src/fsharp/CompileOptions.fsi | 2 +- src/fsharp/ConstraintSolver.fs | 14 +- src/fsharp/DetupleArgs.fs | 2 +- src/fsharp/DotNetFrameworkDependencies.fs | 2 +- src/fsharp/ErrorLogger.fs | 16 +- src/fsharp/ExtensionTyping.fs | 2 +- src/fsharp/IlxGen.fs | 46 +- src/fsharp/InfoReader.fs | 12 +- src/fsharp/InnerLambdasToTopLevelFuncs.fs | 4 +- src/fsharp/InternalCollections.fs | 30 +- src/fsharp/LanguageFeatures.fs | 2 +- src/fsharp/LanguageFeatures.fsi | 2 +- src/fsharp/LexFilter.fs | 28 +- src/fsharp/LowerCallsAndSeqs.fs | 14 +- src/fsharp/MethodCalls.fs | 12 +- src/fsharp/NameResolution.fs | 22 +- src/fsharp/NameResolution.fsi | 2 +- src/fsharp/NicePrint.fs | 24 +- src/fsharp/Optimizer.fs | 26 +- src/fsharp/PatternMatchCompilation.fs | 4 +- src/fsharp/PostInferenceChecks.fs | 10 +- src/fsharp/PrettyNaming.fs | 2 +- .../SimulatedMSBuildReferenceResolver.fs | 24 +- src/fsharp/TastOps.fs | 22 +- src/fsharp/TastOps.fsi | 18 +- src/fsharp/TastPickle.fs | 4 +- src/fsharp/TypeChecker.fs | 68 +- src/fsharp/ast.fs | 50 +- src/fsharp/fsi/fsi.fs | 14 +- src/fsharp/fsi/fsi.fsi | 12 +- src/fsharp/infos.fs | 4 +- src/fsharp/layout.fs | 2 +- src/fsharp/lib.fs | 32 +- src/fsharp/range.fs | 6 +- src/fsharp/service/FSharpCheckerResults.fs | 6 +- src/fsharp/service/FSharpCheckerResults.fsi | 2 +- src/fsharp/service/IncrementalBuild.fs | 130 +-- src/fsharp/service/IncrementalBuild.fsi | 6 +- src/fsharp/service/QuickParse.fs | 8 +- src/fsharp/service/QuickParse.fsi | 6 +- src/fsharp/service/Reactor.fs | 2 +- src/fsharp/service/ServiceAnalysis.fs | 2 +- src/fsharp/service/ServiceAssemblyContent.fs | 14 +- src/fsharp/service/ServiceAssemblyContent.fsi | 8 +- src/fsharp/service/ServiceLexing.fs | 18 +- src/fsharp/service/ServiceLexing.fsi | 4 +- src/fsharp/service/ServiceNavigation.fs | 8 +- src/fsharp/service/ServiceStructure.fs | 12 +- src/fsharp/service/ServiceStructure.fsi | 2 +- src/fsharp/service/ServiceUntypedParse.fs | 4 +- src/fsharp/service/service.fs | 14 +- src/fsharp/symbols/Exprs.fs | 56 +- src/fsharp/symbols/Exprs.fsi | 2 +- src/fsharp/symbols/SymbolHelpers.fs | 8 +- src/fsharp/symbols/SymbolHelpers.fsi | 2 +- src/fsharp/symbols/Symbols.fs | 10 +- src/fsharp/symbols/Symbols.fsi | 2 +- src/fsharp/tast.fs | 28 +- src/utils/CompilerLocationUtils.fs | 18 +- src/utils/HashMultiMap.fs | 12 +- src/utils/prim-lexing.fsi | 2 +- src/utils/prim-parsing.fs | 2 +- 74 files changed, 1326 insertions(+), 546 deletions(-) create mode 100644 fcs/FSharp.Compiler.Service.sln.DotSettings diff --git a/fcs/FSharp.Compiler.Service.sln.DotSettings b/fcs/FSharp.Compiler.Service.sln.DotSettings new file mode 100644 index 00000000000..59e0b85499d --- /dev/null +++ b/fcs/FSharp.Compiler.Service.sln.DotSettings @@ -0,0 +1,780 @@ + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True~ \ No newline at end of file diff --git a/src/absil/bytes.fs b/src/absil/bytes.fs index a272b99a454..e3996fe3bfd 100644 --- a/src/absil/bytes.fs +++ b/src/absil/bytes.fs @@ -87,10 +87,10 @@ type internal ByteBuffer = let n = arr.Length let newSize = buf.bbCurrent + n buf.Ensure newSize - let bbarr = buf.bbArray - let bbbase = buf.bbCurrent + let bbArr = buf.bbArray + let bbBase = buf.bbCurrent for i = 0 to n - 1 do - bbarr.[bbbase + i] <- byte arr.[i] + bbArr.[bbBase + i] <- byte arr.[i] buf.bbCurrent <- newSize member bb.FixupInt32 pos n = diff --git a/src/absil/il.fs b/src/absil/il.fs index 51b75e55fbb..a199c6879e4 100644 --- a/src/absil/il.fs +++ b/src/absil/il.fs @@ -2962,7 +2962,7 @@ let mkILNonGenericEmptyCtor tag superTy = mkILCtor (ILMemberAccess.Public, [], mkMethodBody (false, [], 8, nonBranchingInstrsToCode ctor, tag)) // -------------------------------------------------------------------- -// Make a static, top level monomophic method - very useful for +// Make a static, top level monomorphic method - very useful for // creating helper ILMethodDefs for internal use. // -------------------------------------------------------------------- @@ -3324,7 +3324,7 @@ let mkILSimpleModule assemblyName modname dll subsystemVersion useHighEntropyVA // [instructions_to_code] makes the basic block structure of code from // a primitive array of instructions. We // do this be iterating over the instructions, pushing new basic blocks -// everytime we encounter an address that has been recorded +// every time we encounter an address that has been recorded // [bbstartToCodeLabelMap]. //----------------------------------------------------------------------- diff --git a/src/absil/ilascii.fs b/src/absil/ilascii.fs index cf8cef0a631..6c89ca69b59 100644 --- a/src/absil/ilascii.fs +++ b/src/absil/ilascii.fs @@ -8,7 +8,7 @@ open FSharp.Compiler.AbstractIL.Internal.Library open FSharp.Compiler.AbstractIL.IL // set to the proper value at CompileOps.fs (BuildFrameworkTcImports) -// Only reelvant when compiling FSharp.Core.dll +// Only relevant when compiling FSharp.Core.dll let parseILGlobals = ref EcmaMscorlibILGlobals /// Table of parsing and pretty printing data for instructions. diff --git a/src/absil/illib.fs b/src/absil/illib.fs index 68b7c8d40a8..70e67a0815d 100644 --- a/src/absil/illib.fs +++ b/src/absil/illib.fs @@ -164,12 +164,12 @@ module Array = /// pass an array byref to reverse it in place let revInPlace (array: 'T []) = if Array.isEmpty array then () else - let arrlen, revlen = array.Length-1, array.Length/2 - 1 - for idx in 0 .. revlen do + let arrLen, revLen = array.Length-1, array.Length/2 - 1 + for idx in 0 .. revLen do let t1 = array.[idx] - let t2 = array.[arrlen-idx] + let t2 = array.[arrLen-idx] array.[idx] <- t2 - array.[arrlen-idx] <- t1 + array.[arrLen-idx] <- t1 /// Async implementation of Array.map. let mapAsync (mapping : 'T -> Async<'U>) (array : 'T[]) : Async<'U[]> = @@ -624,7 +624,7 @@ type CompilationThreadToken() = interface ExecutionToken let RequireCompilationThread (_ctok: CompilationThreadToken) = () /// Represents a place in the compiler codebase where we are passed a CompilationThreadToken unnecessarily. -/// This reprents code that may potentially not need to be executed on the compilation thread. +/// This represents code that may potentially not need to be executed on the compilation thread. let DoesNotRequireCompilerThreadTokenAndCouldPossiblyBeMadeConcurrent (_ctok: CompilationThreadToken) = () /// Represents a place in the compiler codebase where we assume we are executing on a compilation thread diff --git a/src/absil/ilmorph.fs b/src/absil/ilmorph.fs index ffd86aa504b..997f6f4a0aa 100644 --- a/src/absil/ilmorph.fs +++ b/src/absil/ilmorph.fs @@ -50,7 +50,7 @@ let code_instr2instr_ty2ty (finstr,fty) (c:ILCode) = Exceptions = c.Exceptions |> List.map (fun e -> { e with Clause = e.Clause |> (function ILExceptionClause.TypeCatch (ilty, b) -> ILExceptionClause.TypeCatch (fty ilty, b) | cl -> cl) }) } // -------------------------------------------------------------------- -// Standard morphisms - mapping tyes etc. +// Standard morphisms - mapping types etc. // -------------------------------------------------------------------- let rec ty_tref2tref f x = diff --git a/src/absil/ilreflect.fs b/src/absil/ilreflect.fs index cf43af269e6..682b44c5ba8 100644 --- a/src/absil/ilreflect.fs +++ b/src/absil/ilreflect.fs @@ -1724,7 +1724,7 @@ let buildMethodImplsPass3 cenv _tref (typB: TypeBuilder) emEnv (mimpl: IL.ILMeth // typeAttributesOf* //---------------------------------------------------------------------------- -let typeAttrbutesOfTypeDefKind x = +let typeAttributesOfTypeDefKind x = match x with // required for a TypeBuilder | ILTypeDefKind.Class -> TypeAttributes.Class @@ -1733,14 +1733,14 @@ let typeAttrbutesOfTypeDefKind x = | ILTypeDefKind.Enum -> TypeAttributes.Class | ILTypeDefKind.Delegate -> TypeAttributes.Class -let typeAttrbutesOfTypeAccess x = +let typeAttributesOfTypeAccess x = match x with | ILTypeDefAccess.Public -> TypeAttributes.Public | ILTypeDefAccess.Private -> TypeAttributes.NotPublic | ILTypeDefAccess.Nested macc -> match macc with | ILMemberAccess.Assembly -> TypeAttributes.NestedAssembly - | ILMemberAccess.CompilerControlled -> failwith "Nested compiler controled." + | ILMemberAccess.CompilerControlled -> failwith "Nested compiler controlled." | ILMemberAccess.FamilyAndAssembly -> TypeAttributes.NestedFamANDAssem | ILMemberAccess.FamilyOrAssembly -> TypeAttributes.NestedFamORAssem | ILMemberAccess.Family -> TypeAttributes.NestedFamily @@ -1929,7 +1929,7 @@ let rec getTypeRefsInType (allTypes: CollectTypes) ty acc = | CollectTypes.ValueTypesOnly -> acc | CollectTypes.All -> getTypeRefsInType allTypes eltType acc | ILType.Value tspec -> - // We usee CollectTypes.All because the .NET type loader appears to always eagerly require all types + // We use CollectTypes.All because the .NET type loader appears to always eagerly require all types // referred to in an instantiation of a generic value type tspec.TypeRef :: List.foldBack (getTypeRefsInType CollectTypes.All) tspec.GenericArgs acc | ILType.Boxed tspec -> diff --git a/src/absil/ilsupp.fs b/src/absil/ilsupp.fs index fb8a98b3494..5c3d108fbb2 100644 --- a/src/absil/ilsupp.fs +++ b/src/absil/ilsupp.fs @@ -757,7 +757,7 @@ type ISymUnmanagedWriter2 = abstract OpenScope: startOffset: int * pRetVal: int byref -> unit abstract CloseScope: endOffset: int -> unit abstract SetScopeRange: scopeID: int * startOffset: int * endOffset: int -> unit - abstract DefineLocalVariable: [] varname: string * + abstract DefineLocalVariable: [] varName: string * attributes: int * cSig: int * []signature: byte[] * @@ -767,7 +767,7 @@ type ISymUnmanagedWriter2 = addr3: int * startOffset: int * endOffset: int -> unit - abstract DefineParameter: [] paramname: string * + abstract DefineParameter: [] paramName: string * attributes: int * sequence: int * addressKind: int * @@ -775,7 +775,7 @@ type ISymUnmanagedWriter2 = addr2: int * addr3: int -> unit abstract DefineField: parent: int * - [] fieldname: string * + [] fieldName: string * attributes: int * cSig: int * []signature: byte[] * @@ -783,7 +783,7 @@ type ISymUnmanagedWriter2 = addr1: int * addr2: int * addr3: int -> unit - abstract DefineGlobalVariable: [] globalvarname: string * + abstract DefineGlobalVariable: [] globalVarName: string * attributes: int * cSig: int * []signature: byte[] * @@ -793,7 +793,7 @@ type ISymUnmanagedWriter2 = addr3: int -> unit abstract Close: unit -> unit abstract SetSymAttribute: parent: int * - [] attname: string * + [] attName: string * cData: int * []data: byte[] -> unit abstract OpenNamespace: [] nsname: string -> unit @@ -822,16 +822,16 @@ type ISymUnmanagedWriter2 = []endColumns: int [] -> unit abstract RemapToken: oldToken: int * newToken: int -> unit abstract Initialize2: emitter: nativeint * - [] tempfilename: string * + [] tempFileName: string * stream: IStream * fullBuild: bool * - [] finalfilename: string -> unit - abstract DefineConstant: [] constname: string * + [] finalFileName: string -> unit + abstract DefineConstant: [] constName: string * value: Object * cSig: int * []signature: byte[] -> unit abstract Abort: unit -> unit - abstract DefineLocalVariable2: [] localvarname2: string * + abstract DefineLocalVariable2: [] localVarName2: string * attributes: int * sigToken: int * addressKind: int * @@ -840,14 +840,14 @@ type ISymUnmanagedWriter2 = addr3: int * startOffset: int * endOffset: int -> unit - abstract DefineGlobalVariable2: [] globalvarname2: string * + abstract DefineGlobalVariable2: [] globalVarName2: string * attributes: int * sigToken: int * addressKind: int * addr1: int * addr2: int * addr3: int -> unit - abstract DefineConstant2: [] constantname2: string * + abstract DefineConstant2: [] constantName2: string * value: Object * sigToken: int -> unit abstract OpenMethod2: method2: int * diff --git a/src/absil/ilwrite.fs b/src/absil/ilwrite.fs index dbd8a288755..1a650e25bce 100644 --- a/src/absil/ilwrite.fs +++ b/src/absil/ilwrite.fs @@ -476,8 +476,8 @@ type MetadataTable<'T> = h.Clear() t |> Array.iteri (fun i x -> h.[x] <- (i+1)) - member tbl.AddUniqueEntry nm geterr x = - if tbl.dict.ContainsKey x then failwith ("duplicate entry '"+geterr x+"' in "+nm+" table") + member tbl.AddUniqueEntry nm getter x = + if tbl.dict.ContainsKey x then failwith ("duplicate entry '"+getter x+"' in "+nm+" table") else tbl.AddSharedEntry x member tbl.GetTableEntry x = tbl.dict.[x] @@ -806,7 +806,7 @@ let getTypeDefOrRefAsUncodedToken (tag, idx) = else failwith "getTypeDefOrRefAsUncodedToken" getUncodedToken tab idx -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer let EmitArrayShape (bb: ByteBuffer) (ILArrayShape shape) = let sized = List.filter (function (_, Some _) -> true | _ -> false) shape let lobounded = List.filter (function (Some _, _) -> true | _ -> false) shape @@ -834,7 +834,7 @@ let callconvToByte ntypars (Callconv (hasthis, bcc)) = | ILArgConvention.VarArg -> e_IMAGE_CEE_CS_CALLCONV_VARARG) -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer let rec EmitTypeSpec cenv env (bb: ByteBuffer) (et, tspec: ILTypeSpec) = if isNil tspec.GenericArgs then bb.EmitByte et @@ -944,7 +944,7 @@ and EmitCallsig cenv env bb (callconv, args: ILTypes, ret, varargs: ILVarArgs, g and GetCallsigAsBytes cenv env x = emitBytesViaBuffer (fun bb -> EmitCallsig cenv env bb x) -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer and EmitTypes cenv env bb (inst: ILTypes) = inst |> List.iter (EmitType cenv env bb) @@ -976,7 +976,7 @@ let rec GetNativeTypeAsBlobIdx cenv (ty: ILNativeType) = and GetNativeTypeAsBytes ty = emitBytesViaBuffer (fun bb -> EmitNativeType bb ty) -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer and EmitNativeType bb ty = if List.memAssoc ty (Lazy.force ILNativeTypeRevMap) then bb.EmitByte (List.assoc ty (Lazy.force ILNativeTypeRevMap)) @@ -1035,7 +1035,7 @@ and EmitNativeType bb ty = let rec GetFieldInitAsBlobIdx cenv (x: ILFieldInit) = GetBytesAsBlobIdx cenv (emitBytesViaBuffer (fun bb -> GetFieldInit bb x)) -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer and GetFieldInit (bb: ByteBuffer) x = match x with | ILFieldInit.String b -> bb.EmitBytes (System.Text.Encoding.Unicode.GetBytes b) @@ -1093,7 +1093,7 @@ let GetTypeAccessFlags access = | ILTypeDefAccess.Nested ILMemberAccess.Public -> 0x00000002 | ILTypeDefAccess.Nested ILMemberAccess.Private -> 0x00000003 | ILTypeDefAccess.Nested ILMemberAccess.Family -> 0x00000004 - | ILTypeDefAccess.Nested ILMemberAccess.CompilerControlled -> failwith "bad type acccess" + | ILTypeDefAccess.Nested ILMemberAccess.CompilerControlled -> failwith "bad type access" | ILTypeDefAccess.Nested ILMemberAccess.FamilyAndAssembly -> 0x00000006 | ILTypeDefAccess.Nested ILMemberAccess.FamilyOrAssembly -> 0x00000007 | ILTypeDefAccess.Nested ILMemberAccess.Assembly -> 0x00000005 @@ -1258,7 +1258,7 @@ and GetFieldDefAsFieldDefIdx cenv tidx fd = // -------------------------------------------------------------------- // ILMethodRef --> ILMethodDef. // -// Only successfuly converts ILMethodRef's referring to +// Only successfully converts ILMethodRef's referring to // methods in the module being emitted. // -------------------------------------------------------------------- @@ -1439,7 +1439,7 @@ and GetFieldSpecAsMemberRefIdx cenv env fspec = let fenv = envForFieldSpec fspec FindOrAddSharedRow cenv TableNames.MemberRef (GetFieldSpecAsMemberRefRow cenv env fenv fspec) -// REVIEW: write into an accumuating buffer +// REVIEW: write into an accumulating buffer and EmitFieldSpecSig cenv env (bb: ByteBuffer) (fspec: ILFieldSpec) = bb.EmitByte e_IMAGE_CEE_CS_CALLCONV_FIELD EmitType cenv env bb fspec.FormalType @@ -1555,8 +1555,8 @@ type CodeBuffer = member codebuf.EmitUncodedToken u = codebuf.EmitInt32 u - member codebuf.RecordReqdStringFixup stringidx = - codebuf.reqdStringFixupsInMethod <- (codebuf.code.Position, stringidx) :: codebuf.reqdStringFixupsInMethod + member codebuf.RecordReqdStringFixup stringIdx = + codebuf.reqdStringFixupsInMethod <- (codebuf.code.Position, stringIdx) :: codebuf.reqdStringFixupsInMethod // Write a special value in that we check later when applying the fixup codebuf.EmitInt32 0xdeadbeef @@ -1592,7 +1592,7 @@ module Codebuf = go 0 (Array.length arr) let applyBrFixups (origCode : byte[]) origExnClauses origReqdStringFixups (origAvailBrFixups: Dictionary) origReqdBrFixups origSeqPoints origScopes = - let orderedOrigReqdBrFixups = origReqdBrFixups |> List.sortBy (fun (_, fixuploc, _) -> fixuploc) + let orderedOrigReqdBrFixups = origReqdBrFixups |> List.sortBy (fun (_, fixupLoc, _) -> fixupLoc) let newCode = ByteBuffer.Create origCode.Length @@ -1732,7 +1732,7 @@ module Codebuf = | true, n -> let relOffset = n - endOfInstr if small then - if Bytes.get newCode newFixupLoc <> 0x98 then failwith "br fixupsanity check failed" + if Bytes.get newCode newFixupLoc <> 0x98 then failwith "br fixup sanity check failed" newCode.[newFixupLoc] <- b0 relOffset else checkFixup32 newCode newFixupLoc 0xf00dd00fl @@ -2820,7 +2820,7 @@ and GenExportedTypesPass3 cenv (ce: ILExportedTypesAndForwarders) = // manifest --> generate Assembly row // -------------------------------------------------------------------- -and GetManifsetAsAssemblyRow cenv m = +and GetManifestAsAssemblyRow cenv m = UnsharedRow [|ULong m.AuxModuleHashAlgorithm UShort (match m.Version with None -> 0us | Some version -> version.Major) @@ -2836,7 +2836,7 @@ and GetManifsetAsAssemblyRow cenv m = | ILAssemblyLongevity.PlatformSystem -> 0x0008) ||| (if m.Retargetable then 0x100 else 0x0) ||| // Setting these causes peverify errors. Hence both ilread and ilwrite ignore them and refuse to set them. - // Any debugging customattributes will automatically propagate + // Any debugging customAttributes will automatically propagate // REVIEW: No longer appears to be the case (if m.JitTracking then 0x8000 else 0x0) ||| (match m.PublicKey with None -> 0x0000 | Some _ -> 0x0001) ||| 0x0000) @@ -2845,7 +2845,7 @@ and GetManifsetAsAssemblyRow cenv m = (match m.Locale with None -> StringE 0 | Some x -> StringE (GetStringHeapIdx cenv x)) |] and GenManifestPass3 cenv m = - let aidx = AddUnsharedRow cenv TableNames.Assembly (GetManifsetAsAssemblyRow cenv m) + let aidx = AddUnsharedRow cenv TableNames.Assembly (GetManifestAsAssemblyRow cenv m) GenSecurityDeclsPass3 cenv (hds_Assembly, aidx) m.SecurityDecls.AsList GenCustomAttrsPass3Or4 cenv (hca_Assembly, aidx) m.CustomAttrs GenExportedTypesPass3 cenv m.ExportedTypes @@ -3033,7 +3033,7 @@ let nochunk next = ({addr= 0x0;size= 0x0; }, next) let count f arr = Array.fold (fun x y -> x + f y) 0x0 arr -module FileSystemUtilites = +module FileSystemUtilities = open System open System.Reflection open System.Globalization @@ -3630,7 +3630,7 @@ let writeBinaryAndReportMappings (outfile, match aref.Version with | Some version when version.Major = 2us -> parseILVersion "2.0.50727.0" | Some v -> v - | None -> failwith "Expected msorlib to have a version number" + | None -> failwith "Expected mscorlib to have a version number" let entryPointToken, code, codePadding, metadata, data, resources, requiredDataFixups, pdbData, mappings, guidStart = writeILMetadataAndCode ((pdbfile <> None), desiredMetadataVersion, ilg, emitTailcalls, deterministic, showTimes) modul next normalizeAssemblyRefs @@ -3859,7 +3859,7 @@ let writeBinaryAndReportMappings (outfile, writeInt32 os timestamp // Update pdbData with new guid and timestamp. Portable and embedded PDBs don't need the ModuleID - // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-determinsitic Windows native code + // Full and PdbOnly aren't supported under deterministic builds currently, they rely on non-deterministic Windows native code { pdbData with ModuleID = final.[0..15] ; Timestamp = timestamp } else writeInt32 os timestamp // date since 1970 @@ -4191,7 +4191,7 @@ let writeBinaryAndReportMappings (outfile, os.Dispose() try - FileSystemUtilites.setExecutablePermission outfile + FileSystemUtilities.setExecutablePermission outfile with _ -> () pdbData, pdbOpt, debugDirectoryChunk, debugDataChunk, debugChecksumPdbChunk, debugEmbeddedPdbChunk, debugDeterministicPdbChunk, textV2P, mappings diff --git a/src/fsharp/CompileOps.fs b/src/fsharp/CompileOps.fs index 5979861c1fd..1cc0837d915 100644 --- a/src/fsharp/CompileOps.fs +++ b/src/fsharp/CompileOps.fs @@ -435,7 +435,7 @@ let SplitRelatedDiagnostics(err: PhasedDiagnostic) = SplitRelatedException err.Exception -let DeclareMesssage = FSharp.Compiler.DiagnosticMessage.DeclareResourceString +let DeclareMessage = FSharp.Compiler.DiagnosticMessage.DeclareResourceString do FSComp.SR.RunStartupValidation() let SeeAlsoE() = DeclareResourceString("SeeAlso", "%s") @@ -1493,15 +1493,15 @@ let OutputPhasedErrorR (os: StringBuilder) (err: PhasedDiagnostic) (canSuggestNa | IntfImplInExtrinsicAugmentation(_) -> os.Append(IntfImplInExtrinsicAugmentationE().Format) |> ignore - | UnresolvedReferenceError(assemblyname, _) + | UnresolvedReferenceError(assemblyName, _) - | UnresolvedReferenceNoRange assemblyname -> - os.Append(UnresolvedReferenceNoRangeE().Format assemblyname) |> ignore + | UnresolvedReferenceNoRange assemblyName -> + os.Append(UnresolvedReferenceNoRangeE().Format assemblyName) |> ignore - | UnresolvedPathReference(assemblyname, pathname, _) + | UnresolvedPathReference(assemblyName, pathname, _) - | UnresolvedPathReferenceNoRange(assemblyname, pathname) -> - os.Append(UnresolvedPathReferenceNoRangeE().Format pathname assemblyname) |> ignore + | UnresolvedPathReferenceNoRange(assemblyName, pathname) -> + os.Append(UnresolvedPathReferenceNoRangeE().Format pathname assemblyName) |> ignore | DeprecatedCommandLineOptionFull(fullText, _) -> os.Append fullText |> ignore @@ -2169,7 +2169,7 @@ type TcConfigBuilder = static member Initial = { - primaryAssembly = PrimaryAssembly.Mscorlib // defaut value, can be overridden using the command line switch + primaryAssembly = PrimaryAssembly.Mscorlib // default value, can be overridden using the command line switch light = None noFeedback = false stackReserveSize = None @@ -2581,7 +2581,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = // Look for an explicit reference to mscorlib/netstandard.dll or System.Runtime.dll and use that to compute clrRoot and targetFrameworkVersion let primaryAssemblyReference, primaryAssemblyExplicitFilenameOpt = computeKnownDllReference(data.primaryAssembly.Name) let fslibReference = - // Look for explict FSharp.Core reference otherwise use version that was referenced by compiler + // Look for explicit FSharp.Core reference otherwise use version that was referenced by compiler let dllReference, fileNameOpt = computeKnownDllReference getFSharpCoreLibraryName match fileNameOpt with | Some _ -> dllReference @@ -2926,7 +2926,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = | None -> None else None - member tcConfig.ResolveLibWithDirectories (ccuLoadFaulureAction, r: AssemblyReference) = + member tcConfig.ResolveLibWithDirectories (ccuLoadFailureAction, r: AssemblyReference) = let m, nm = r.Range, r.Text use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter // test for both libraries and executables @@ -2944,7 +2944,7 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = match rs |> List.tryPick (fun r -> tcConfig.TryResolveLibWithDirectories r) with | Some res -> Some res | None -> - match ccuLoadFaulureAction with + match ccuLoadFailureAction with | CcuLoadFailureAction.RaiseError -> let searchMessage = String.concat "\n " (tcConfig.GetSearchPathsForLibraryFiles()) raise (FileNameNotResolved(nm, searchMessage, m)) @@ -3189,14 +3189,14 @@ let QualFileNameOfImpls filename specs = | [SynModuleOrNamespace(_, _, kind, _, _, _, _, m)] when not kind.IsModule -> QualFileNameOfFilename m filename | _ -> QualFileNameOfFilename (mkRange filename pos0 pos0) filename -let PrepandPathToQualFileName x (QualifiedNameOfFile q) = ComputeQualifiedNameOfFileFromUniquePath (q.idRange, pathOfLid x@[q.idText]) -let PrepandPathToImpl x (SynModuleOrNamespace(p, b, c, d, e, f, g, h)) = SynModuleOrNamespace(x@p, b, c, d, e, f, g, h) -let PrepandPathToSpec x (SynModuleOrNamespaceSig(p, b, c, d, e, f, g, h)) = SynModuleOrNamespaceSig(x@p, b, c, d, e, f, g, h) +let PrependPathToQualFileName x (QualifiedNameOfFile q) = ComputeQualifiedNameOfFileFromUniquePath (q.idRange, pathOfLid x@[q.idText]) +let PrependPathToImpl x (SynModuleOrNamespace(p, b, c, d, e, f, g, h)) = SynModuleOrNamespace(x@p, b, c, d, e, f, g, h) +let PrependPathToSpec x (SynModuleOrNamespaceSig(p, b, c, d, e, f, g, h)) = SynModuleOrNamespaceSig(x@p, b, c, d, e, f, g, h) let PrependPathToInput x inp = match inp with - | ParsedInput.ImplFile (ParsedImplFileInput (b, c, q, d, hd, impls, e)) -> ParsedInput.ImplFile (ParsedImplFileInput (b, c, PrepandPathToQualFileName x q, d, hd, List.map (PrepandPathToImpl x) impls, e)) - | ParsedInput.SigFile (ParsedSigFileInput (b, q, d, hd, specs)) -> ParsedInput.SigFile (ParsedSigFileInput (b, PrepandPathToQualFileName x q, d, hd, List.map (PrepandPathToSpec x) specs)) + | ParsedInput.ImplFile (ParsedImplFileInput (b, c, q, d, hd, impls, e)) -> ParsedInput.ImplFile (ParsedImplFileInput (b, c, PrependPathToQualFileName x q, d, hd, List.map (PrependPathToImpl x) impls, e)) + | ParsedInput.SigFile (ParsedSigFileInput (b, q, d, hd, specs)) -> ParsedInput.SigFile (ParsedSigFileInput (b, PrependPathToQualFileName x q, d, hd, List.map (PrependPathToSpec x) specs)) let ComputeAnonModuleName check defaultNamespace filename (m: range) = let modname = CanonicalizeFilename filename @@ -3583,17 +3583,17 @@ let GetOptimizationDataResourceName (r: ILResource) = let IsReflectedDefinitionsResource (r: ILResource) = r.Name.StartsWithOrdinal(QuotationPickler.SerializedReflectedDefinitionsResourceNameBase) -let MakeILResource rname bytes = - { Name = rname +let MakeILResource rName bytes = + { Name = rName Location = ILResourceLocation.LocalOut bytes Access = ILResourceAccess.Public CustomAttrsStored = storeILCustomAttrs emptyILCustomAttrs MetadataIndex = NoMetadataIdx } -let PickleToResource inMem file (g: TcGlobals) scope rname p x = +let PickleToResource inMem file (g: TcGlobals) scope rName p x = let file = PathMap.apply g.pathMap file - { Name = rname + { Name = rName Location = (let bytes = pickleObjWithDanglingCcus inMem file g scope p x in ILResourceLocation.LocalOut bytes) Access = ILResourceAccess.Public CustomAttrsStored = storeILCustomAttrs emptyILCustomAttrs @@ -3607,7 +3607,7 @@ let WriteSignatureData (tcConfig: TcConfig, tcGlobals, exportRemapping, ccu: Ccu let mspec = ApplyExportRemappingToEntity tcGlobals exportRemapping mspec // For historical reasons, we use a different resource name for FSharp.Core, so older F# compilers // don't complain when they see the resource. - let rname = if ccu.AssemblyName = getFSharpCoreLibraryName then FSharpSignatureDataResourceName2 else FSharpSignatureDataResourceName + let rName = if ccu.AssemblyName = getFSharpCoreLibraryName then FSharpSignatureDataResourceName2 else FSharpSignatureDataResourceName let includeDir = if String.IsNullOrEmpty tcConfig.implicitIncludeDir then "" @@ -3616,7 +3616,7 @@ let WriteSignatureData (tcConfig: TcConfig, tcGlobals, exportRemapping, ccu: Ccu |> System.IO.Path.GetFullPath |> PathMap.applyDir tcGlobals.pathMap - PickleToResource inMem file tcGlobals ccu (rname+ccu.AssemblyName) pickleCcuInfo + PickleToResource inMem file tcGlobals ccu (rName+ccu.AssemblyName) pickleCcuInfo { mspec=mspec compileTimeWorkingDir=includeDir usesQuotations = ccu.UsesFSharp20PlusQuotations } @@ -3627,8 +3627,8 @@ let GetOptimizationData (file, ilScopeRef, ilModule, byteReader) = let WriteOptimizationData (tcGlobals, file, inMem, ccu: CcuThunk, modulInfo) = // For historical reasons, we use a different resource name for FSharp.Core, so older F# compilers // don't complain when they see the resource. - let rname = if ccu.AssemblyName = getFSharpCoreLibraryName then FSharpOptimizationDataResourceName2 else FSharpOptimizationDataResourceName - PickleToResource inMem file tcGlobals ccu (rname+ccu.AssemblyName) Optimizer.p_CcuOptimizationInfo modulInfo + let rName = if ccu.AssemblyName = getFSharpCoreLibraryName then FSharpOptimizationDataResourceName2 else FSharpOptimizationDataResourceName + PickleToResource inMem file tcGlobals ccu (rName+ccu.AssemblyName) Optimizer.p_CcuOptimizationInfo modulInfo //---------------------------------------------------------------------------- // Abstraction for project reference @@ -4118,7 +4118,7 @@ and [] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse (typeProviderEnvironment, tcConfig: TcConfig, m, entity: Entity, - injectedNamspace, remainingNamespace, + injectedNamespace, remainingNamespace, provider, st: Tainted option) = match remainingNamespace with @@ -4126,13 +4126,13 @@ and [] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse // Inject the namespace entity match entity.ModuleOrNamespaceType.ModulesAndNamespacesByDemangledName.TryFind next with | Some childEntity -> - tcImports.InjectProvidedNamespaceOrTypeIntoEntity (typeProviderEnvironment, tcConfig, m, childEntity, next :: injectedNamspace, rest, provider, st) + tcImports.InjectProvidedNamespaceOrTypeIntoEntity (typeProviderEnvironment, tcConfig, m, childEntity, next :: injectedNamespace, rest, provider, st) | None -> // Build up the artificial namespace if there is not a real one. - let cpath = CompPath(ILScopeRef.Local, injectedNamspace |> List.rev |> List.map (fun n -> (n, ModuleOrNamespaceKind.Namespace)) ) + let cpath = CompPath(ILScopeRef.Local, injectedNamespace |> List.rev |> List.map (fun n -> (n, ModuleOrNamespaceKind.Namespace)) ) let newNamespace = NewModuleOrNamespace (Some cpath) taccessPublic (ident(next, rangeStartup)) XmlDoc.Empty [] (MaybeLazy.Strict (NewEmptyModuleOrNamespaceType Namespace)) entity.ModuleOrNamespaceType.AddModuleOrNamespaceByMutation newNamespace - tcImports.InjectProvidedNamespaceOrTypeIntoEntity (typeProviderEnvironment, tcConfig, m, newNamespace, next :: injectedNamspace, rest, provider, st) + tcImports.InjectProvidedNamespaceOrTypeIntoEntity (typeProviderEnvironment, tcConfig, m, newNamespace, next :: injectedNamespace, rest, provider, st) | [] -> match st with | Some st -> @@ -4584,7 +4584,7 @@ and [] TcImports(tcConfigP: TcConfigProvider, initialResolutions: TcAsse | None -> ErrorD(AssemblyNotResolved(assemblyReference.Text, assemblyReference.Range)) else - // This is a previously unencounterd assembly. Resolve it and add it to the list. + // This is a previously unencountered assembly. Resolve it and add it to the list. // But don't cache resolution failures because the assembly may appear on the disk later. let resolved, unresolved = TcConfig.TryResolveLibsUsingMSBuildRules(tcConfig, [ assemblyReference ], assemblyReference.Range, mode) match resolved, unresolved with @@ -5187,7 +5187,7 @@ module private ScriptPreprocessClosure = filename, sourceText, codeContext, useSimpleResolution, useFsiAuxLib, useSdkRefs, lexResourceManager: Lexhelp.LexResourceManager, - applyCommmandLineArgs, assumeDotNetFramework, + applyCommandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = // Resolve the basic references such as FSharp.Core.dll first, before processing any #I directives in the script @@ -5198,7 +5198,7 @@ module private ScriptPreprocessClosure = let tcConfig = CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, - useFsiAuxLib, None, applyCommmandLineArgs, assumeDotNetFramework, + useFsiAuxLib, None, applyCommandLineArgs, assumeDotNetFramework, useSdkRefs, tryGetMetadataSnapshot, reduceMemoryUsage) let resolutions0, _unresolvedReferences = GetAssemblyResolutionInformation(ctok, tcConfig) @@ -5208,7 +5208,7 @@ module private ScriptPreprocessClosure = let tcConfig = CreateScriptTextTcConfig(legacyReferenceResolver, defaultFSharpBinariesDir, filename, codeContext, useSimpleResolution, useFsiAuxLib, Some references0, - applyCommmandLineArgs, assumeDotNetFramework, useSdkRefs, + applyCommandLineArgs, assumeDotNetFramework, useSdkRefs, tryGetMetadataSnapshot, reduceMemoryUsage) let closureSources = [ClosureSource(filename, range0, sourceText, true)] @@ -5238,13 +5238,13 @@ type LoadClosure with (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename: string, sourceText: ISourceText, codeContext, useSimpleResolution: bool, useFsiAuxLib, useSdkRefs, lexResourceManager: Lexhelp.LexResourceManager, - applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = + applyCommandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) = use unwindBuildPhase = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse ScriptPreprocessClosure.GetFullClosureOfScriptText (ctok, legacyReferenceResolver, defaultFSharpBinariesDir, filename, sourceText, codeContext, useSimpleResolution, useFsiAuxLib, useSdkRefs, lexResourceManager, - applyCommmandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) + applyCommandLineArgs, assumeDotNetFramework, tryGetMetadataSnapshot, reduceMemoryUsage) /// Analyze a set of script files and find the closure of their references. static member ComputeClosureOfScriptFiles diff --git a/src/fsharp/CompileOps.fsi b/src/fsharp/CompileOps.fsi index 364336f32d6..51b10bc0287 100644 --- a/src/fsharp/CompileOps.fsi +++ b/src/fsharp/CompileOps.fsi @@ -63,7 +63,7 @@ val ComputeQualifiedNameOfFileFromUniquePath: range * string list -> Ast.Qualifi val PrependPathToInput: Ast.Ident list -> Ast.ParsedInput -> Ast.ParsedInput -/// State used to de-deuplicate module names along a list of file names +/// State used to de-deduplicate module names along a list of file names type ModuleNamesDict = Map> /// Checks if a ParsedInput is using a module name that was already given and deduplicates the name if needed. diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index c4595d2dc24..29e854a83f1 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -1670,7 +1670,7 @@ let ReportTime (tcConfig:TcConfig) descr = // OPTIMIZATION - support - addDllToOptEnv //---------------------------------------------------------------------------- -let AddExternalCcuToOpimizationEnv tcGlobals optEnv (ccuinfo: ImportedAssembly) = +let AddExternalCcuToOptimizationEnv tcGlobals optEnv (ccuinfo: ImportedAssembly) = match ccuinfo.FSharpOptimizationData.Force() with | None -> optEnv | Some data -> Optimizer.BindCcu ccuinfo.FSharpViewOfMetadata data optEnv tcGlobals @@ -1682,7 +1682,7 @@ let AddExternalCcuToOpimizationEnv tcGlobals optEnv (ccuinfo: ImportedAssembly) let GetInitialOptimizationEnv (tcImports:TcImports, tcGlobals:TcGlobals) = let ccuinfos = tcImports.GetImportedAssemblies() let optEnv = Optimizer.IncrementalOptimizationEnv.Empty - let optEnv = List.fold (AddExternalCcuToOpimizationEnv tcGlobals) optEnv ccuinfos + let optEnv = List.fold (AddExternalCcuToOptimizationEnv tcGlobals) optEnv ccuinfos optEnv let ApplyAllOptimizations (tcConfig:TcConfig, tcGlobals, tcVal, outfile, importMap, isIncrementalFragment, optEnv, ccu:CcuThunk, implFiles) = diff --git a/src/fsharp/CompileOptions.fsi b/src/fsharp/CompileOptions.fsi index e6e010bff2c..f1ea7d44cdc 100644 --- a/src/fsharp/CompileOptions.fsi +++ b/src/fsharp/CompileOptions.fsi @@ -76,7 +76,7 @@ val SetTargetProfile : TcConfigBuilder -> string -> unit val GetGeneratedILModuleName : CompilerTarget -> string -> string val GetInitialOptimizationEnv : TcImports * TcGlobals -> IncrementalOptimizationEnv -val AddExternalCcuToOpimizationEnv : TcGlobals -> IncrementalOptimizationEnv -> ImportedAssembly -> IncrementalOptimizationEnv +val AddExternalCcuToOptimizationEnv : TcGlobals -> IncrementalOptimizationEnv -> ImportedAssembly -> IncrementalOptimizationEnv val ApplyAllOptimizations : TcConfig * TcGlobals * ConstraintSolver.TcValF * string * ImportMap * bool * IncrementalOptimizationEnv * CcuThunk * TypedImplFile list -> TypedAssemblyAfterOptimization * Optimizer.LazyModuleInfo * IncrementalOptimizationEnv val CreateIlxAssemblyGenerator : TcConfig * TcImports * TcGlobals * ConstraintSolver.TcValF * CcuThunk -> IlxGen.IlxAssemblyGenerator diff --git a/src/fsharp/ConstraintSolver.fs b/src/fsharp/ConstraintSolver.fs index 1e59e05b526..f5aade84008 100644 --- a/src/fsharp/ConstraintSolver.fs +++ b/src/fsharp/ConstraintSolver.fs @@ -14,7 +14,7 @@ // The constraints are immediately processed into a normal form, in particular // - type equations on inference parameters: 'tp = ty // - type inequations on inference parameters: 'tp :> ty -// - other constraints on inference paramaters +// - other constraints on inference parameters // // The state of the inference engine is kept in imperative mutations to inference // type variables. @@ -257,7 +257,7 @@ let MakeConstraintSolverEnv contextInfo css m denv = { SolverState = css m = m eContextInfo = contextInfo - // Indicates that when unifiying ty1 = ty2, only type variables in ty1 may be solved + // Indicates that when unifying ty1 = ty2, only type variables in ty1 may be solved MatchingOnly = false EquivEnv = TypeEquivEnv.Empty DisplayEnv = denv } @@ -2110,7 +2110,7 @@ and CanMemberSigsMatchUpToCheck | Some calledArg -> if isArray1DTy g calledArg.CalledArgumentType then let paramArrayElemTy = destArrayTy g calledArg.CalledArgumentType - let reflArgInfo = calledArg.ReflArgInfo // propgate the reflected-arg info to each param array argument + let reflArgInfo = calledArg.ReflArgInfo // propagate the reflected-arg info to each param array argument match calledMeth.ParamArrayCallerArgs with | Some args -> for callerArg in args do @@ -2493,9 +2493,9 @@ and ResolveOverloading if c <> 0 then c else 0 - let better (candidate: CalledMeth<_>, candidateWarnings, _) (other: CalledMeth<_>, otherwarnings, _) = + let better (candidate: CalledMeth<_>, candidateWarnings, _) (other: CalledMeth<_>, otherWarnings, _) = let candidateWarnCount = List.length candidateWarnings - let otherWarnCount = List.length otherwarnings + let otherWarnCount = List.length otherWarnings // Prefer methods that don't give "this code is less generic" warnings // Note: Relies on 'compare' respecting true > false let c = compare (candidateWarnCount = 0) (otherWarnCount = 0) @@ -2862,10 +2862,10 @@ let CodegenWitnessThatTypeSupportsTraitConstraint tcVal g amap m (traitInfo: Tra | Choice1Of5(minfo, methArgTys) -> let argExprs = // FIX for #421894 - typechecker assumes that coercion can be applied for the trait calls arguments but codegen doesn't emit coercion operations - // result - generation of non-verifyable code + // result - generation of non-verifiable code // fix - apply coercion for the arguments (excluding 'receiver' argument in instance calls) - // flatten list of argument types (looks like trait calls with curried arguments are not supported so we can just convert argument list in straighforward way) + // flatten list of argument types (looks like trait calls with curried arguments are not supported so we can just convert argument list in straightforward way) let argTypes = minfo.GetParamTypes(amap, m, methArgTys) |> List.concat diff --git a/src/fsharp/DetupleArgs.fs b/src/fsharp/DetupleArgs.fs index b15bae8f248..309e358ff97 100644 --- a/src/fsharp/DetupleArgs.fs +++ b/src/fsharp/DetupleArgs.fs @@ -199,7 +199,7 @@ module GlobalUsageAnalysis = TopLevelBindings = Zset.empty valOrder IterationIsAtTopLevel = true } - /// Log the use of a value with a particular tuple chape at a callsite + /// Log the use of a value with a particular tuple shape at a callsite /// Note: this routine is called very frequently let logUse (f: Val) tup z = {z with Uses = diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index faae31ba35b..2032063334b 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -166,7 +166,7 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies | Some v -> yield v // These are the Portable-profile and .NET Standard 1.6 dependencies of FSharp.Core.dll. These are needed - // when an F# sript references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers + // when an F# script references an F# profile 7, 78, 259 or .NET Standard 1.6 component which in turn refers // to FSharp.Core for profile 7, 78, 259 or .NET Standard. yield "netstandard" yield "System.Runtime" // lots of types diff --git a/src/fsharp/ErrorLogger.fs b/src/fsharp/ErrorLogger.fs index 5760aef8a2a..c37a3395121 100755 --- a/src/fsharp/ErrorLogger.fs +++ b/src/fsharp/ErrorLogger.fs @@ -88,10 +88,10 @@ exception Deprecated of string * range exception Experimental of string * range exception PossibleUnverifiableCode of range -exception UnresolvedReferenceNoRange of (*assemblyname*) string -exception UnresolvedReferenceError of (*assemblyname*) string * range -exception UnresolvedPathReferenceNoRange of (*assemblyname*) string * (*path*) string -exception UnresolvedPathReference of (*assemblyname*) string * (*path*) string * range +exception UnresolvedReferenceNoRange of (*assemblyName*) string +exception UnresolvedReferenceError of (*assemblyName*) string * range +exception UnresolvedPathReferenceNoRange of (*assemblyName*) string * (*path*) string +exception UnresolvedPathReference of (*assemblyName*) string * (*path*) string * range @@ -197,7 +197,7 @@ type PhasedDiagnostic = /// Construct a phased error static member Create(exn:exn, phase:BuildPhase) : PhasedDiagnostic = - // FUTURE: renable this assert, which has historically triggered in some compiler service scenarios + // FUTURE: reenable this assert, which has historically triggered in some compiler service scenarios // System.Diagnostics.Debug.Assert(phase<>BuildPhase.DefaultPhase, sprintf "Compile error seen with no phase to attribute it to.%A %s %s" phase exn.Message exn.StackTrace ) {Exception = exn; Phase=phase} @@ -281,7 +281,7 @@ let DiscardErrorsLogger = let AssertFalseErrorLogger = { new ErrorLogger("AssertFalseErrorLogger") with - // TODO: renable these asserts in the compiler service + // TODO: reenable these asserts in the compiler service member x.DiagnosticSink(phasedError, isError) = (* assert false; *) () member x.ErrorCount = (* assert false; *) 0 } @@ -313,7 +313,7 @@ type internal CompileThreadStatic = static member BuildPhase with get() = match box CompileThreadStatic.buildPhase with - // FUTURE: renable these asserts, which have historically fired in some compiler service scernaios + // FUTURE: reenable these asserts, which have historically fired in some compiler service scenarios | null -> (* assert false; *) BuildPhase.DefaultPhase | _ -> CompileThreadStatic.buildPhase and set v = CompileThreadStatic.buildPhase <- v @@ -606,7 +606,7 @@ let TryD f g = } | res -> res -let rec RepeatWhileD ndeep body = body ndeep ++ (fun x -> if x then RepeatWhileD (ndeep+1) body else CompleteD) +let rec RepeatWhileD nDeep body = body nDeep ++ (fun x -> if x then RepeatWhileD (nDeep+1) body else CompleteD) let AtLeastOneD f l = MapD f l ++ (fun res -> ResultD (List.exists id res)) diff --git a/src/fsharp/ExtensionTyping.fs b/src/fsharp/ExtensionTyping.fs index c075e0dbe96..077efaa9398 100755 --- a/src/fsharp/ExtensionTyping.fs +++ b/src/fsharp/ExtensionTyping.fs @@ -904,7 +904,7 @@ module internal ExtensionTyping = let namespaceName = TryTypeMember(st, name, "Namespace", m, FSComp.SR.invalidNamespaceForProvidedType(), fun st -> st.Namespace) |> unmarshal let fullName = TryTypeMemberNonNull(st, name, "FullName", m, FSComp.SR.invalidFullNameForProvidedType(), fun st -> st.FullName) |> unmarshal ValidateExpectedName m expectedPath expectedName st - // Must be able to call (GetMethods|GetEvents|GetPropeties|GetNestedTypes|GetConstructors)(bindingFlags). + // Must be able to call (GetMethods|GetEvents|GetProperties|GetNestedTypes|GetConstructors)(bindingFlags). let usedMembers : Tainted[] = // These are the members the compiler will actually use [| for x in TryTypeMemberArray(st, fullName, "GetMethods", m, fun st -> st.GetMethods()) -> x.Coerce m diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 62300df6766..bdf333314ef 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -143,9 +143,9 @@ let NewCounter nm = let CountClosure = NewCounter "closures" -let CountMethodDef = NewCounter "IL method defintitions corresponding to values" +let CountMethodDef = NewCounter "IL method definitions corresponding to values" -let CountStaticFieldDef = NewCounter "IL field defintitions corresponding to values" +let CountStaticFieldDef = NewCounter "IL field definitions corresponding to values" let CountCallFuncInstructions = NewCounter "callfunc instructions (indirect calls)" @@ -225,7 +225,7 @@ type cenv = amap: ImportMap /// A callback for TcVal in the typechecker. Used to generalize values when finding witnesses. - /// It is unfortunate this is needed but it is until we supply witnesses through the compiation. + /// It is unfortunate this is needed but it is until we supply witnesses through the compilation. TcVal: ConstraintSolver.TcValF /// The TAST for the assembly being emitted @@ -397,7 +397,7 @@ type TypeReprEnv(reprs: Map, count: int) = uint16 666 /// Add an additional type parameter to the environment. If the parameter is a units-of-measure parameter - /// then it is ignored, since it doesn't corespond to a .NET type parameter. + /// then it is ignored, since it doesn't correspond to a .NET type parameter. member tyenv.AddOne (tp: Typar) = if IsNonErasedTypar tp then TypeReprEnv(reprs.Add (tp.Stamp, uint16 count), count + 1) @@ -1023,7 +1023,7 @@ let ComputeStorageForFSharpMember amap g topValInfo memberInfo (vref: ValRef) m let mspec, _, _, paramInfos, retInfo, methodArgTys = GetMethodSpecForMemberVal amap g memberInfo vref Method (topValInfo, vref, mspec, m, paramInfos, methodArgTys, retInfo) -/// Compute the representation information for an F#-declared function in a module or an F#-decalared extension member. +/// Compute the representation information for an F#-declared function in a module or an F#-declared extension member. /// Note, there is considerable overlap with ComputeStorageForFSharpMember/GetMethodSpecForMemberVal and these could be /// rationalized. let ComputeStorageForFSharpFunctionOrFSharpExtensionMember amap (g:TcGlobals) cloc topValInfo (vref: ValRef) m = @@ -1050,7 +1050,7 @@ let IsFSharpValCompiledAsMethod g (v: Val) = | _ -> true /// Determine how a top level value is represented, when it is being represented -/// as a method. This depends on its type and other representation inforrmation. +/// as a method. This depends on its type and other representation information. /// If it's a function or is polymorphic, then it gets represented as a /// method (possibly and instance method). Otherwise it gets represented as a /// static field and property. @@ -1102,7 +1102,7 @@ let ComputeStorageForNonLocalTopVal amap g cloc modref (v: Val) = | None -> error(InternalError("ComputeStorageForNonLocalTopVal, expected an arity for " + v.LogicalName, v.Range)) | Some _ -> ComputeStorageForTopVal (amap, g, None, false, NoShadowLocal, mkNestedValRef modref v, cloc) -/// Determine how all the F#-decalred top level values, functions and members are represented, for an external module or namespace. +/// Determine how all the F#-declared top level values, functions and members are represented, for an external module or namespace. let rec AddStorageForNonLocalModuleOrNamespaceRef amap g cloc acc (modref: ModuleOrNamespaceRef) (modul: ModuleOrNamespace) = let acc = (acc, modul.ModuleOrNamespaceType.ModuleAndNamespaceDefinitions) ||> List.fold (fun acc smodul -> @@ -1206,7 +1206,7 @@ let AddIncrementalLocalAssemblyFragmentToIlxGenEnv (amap: ImportMap, isIncrement // Generate debugging marks //-------------------------------------------------------------------------- -/// Generate IL debuging information. +/// Generate IL debugging information. let GenILSourceMarker (g: TcGlobals) (m: range) = ILSourceMarker.Create(document=g.memoize_file m.FileIndex, line=m.StartLine, @@ -1215,7 +1215,7 @@ let GenILSourceMarker (g: TcGlobals) (m: range) = endLine= m.EndLine, endColumn=m.EndColumn+1) -/// Optionally generate IL debuging information. +/// Optionally generate IL debugging information. let GenPossibleILSourceMarker cenv m = if cenv.opts.generateDebugSymbols then Some (GenILSourceMarker cenv.g m ) @@ -1520,14 +1520,14 @@ type AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbu scriptInitFspecs <- (fieldSpec, range) :: scriptInitFspecs /// This initializes the script in #load and fsc command-line order causing their - /// sideeffects to be executed. + /// side effects to be executed. member mgbuf.AddInitializeScriptsInOrderToEntryPoint () = // Get the entry point and initialized any scripts in order. match explicitEntryPointInfo with | Some tref -> - let IntializeCompiledScript(fspec, m) = + let InitializeCompiledScript(fspec, m) = mgbuf.AddExplicitInitToSpecificMethodDef((fun (md: ILMethodDef) -> md.IsEntryPoint), tref, fspec, GenPossibleILSourceMarker cenv m, [], []) - scriptInitFspecs |> List.iter IntializeCompiledScript + scriptInitFspecs |> List.iter InitializeCompiledScript | None -> () member __.GenerateRawDataValueType (cloc, size) = @@ -2227,7 +2227,7 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = | ValStorage.Local _ -> true | _ -> false ) -> - // application of local type functions with type parameters = measure types and body = local value - inine the body + // application of local type functions with type parameters = measure types and body = local value - inline the body GenExpr cenv cgbuf eenv sp v sequel | Expr.App (f,fty, tyargs, args, m) -> GenApp cenv cgbuf eenv (f, fty, tyargs, args, m) sequel @@ -2736,7 +2736,7 @@ and GenCoerce cenv cgbuf eenv (e, tgty, m, srcty) sequel = GenExpr cenv cgbuf eenv SPSuppress e Continue let ilToTy = GenType cenv.amap m eenv.tyenv tgty // Section "III.1.8.1.3 Merging stack states" of ECMA-335 implies that no unboxing - // is required, but we still push the coerce'd type on to the code gen buffer. + // is required, but we still push the coerced type on to the code gen buffer. CG.EmitInstrs cgbuf (pop 1) (Push [ilToTy]) [] GenSequel cenv eenv.cloc cgbuf sequel ) else ( @@ -4636,7 +4636,7 @@ and GetIlxClosureInfo cenv m isLocalTypeFunc selfv eenvouter expr = and IsNamedLocalTypeFuncVal g (v: Val) expr = not v.IsCompiledAsTopLevel && - IsGenericValWithGenericContraints g v && + IsGenericValWithGenericConstraints g v && (match stripExpr expr with Expr.TyLambda _ -> true | _ -> false) /// Generate the information relevant to the contract portion of a named local type function @@ -6582,14 +6582,14 @@ and GenTopImpl cenv (mgbuf: AssemblyBuilder) mainInfoOpt eenv (TImplFile (qname, | Some mainInfo -> // Generate an explicit main method. If necessary, make a class constructor as - // well for the bindings earlier in the file containing the entrypoint. + // well for the bindings earlier in the file containing the entry point. match mgbuf.GetExplicitEntryPointInfo() with // Final file, explicit entry point: place the code in a .cctor, and add code to main that forces the .cctor (if topCode has initialization effect). | Some tref -> if doesSomething then lazyInitInfo.Add (fun fspec feefee seqpt -> - // This adds the explicit init of the .cctor to the explicit entrypoint main method + // This adds the explicit init of the .cctor to the explicit entry point main method mgbuf.AddExplicitInitToSpecificMethodDef((fun md -> md.IsEntryPoint), tref, fspec, GenPossibleILSourceMarker cenv m, feefee, seqpt)) let cctorMethDef = mkILClassCtor (MethodBody.IL topCode) @@ -7119,7 +7119,7 @@ and GenTypeDef cenv mgbuf lazyInitInfo eenv m (tycon: Tycon) = //printfn "sprintf not found" () | _, None -> - //printfn "new formatnot found" + //printfn "new format not found" () | _ -> //printfn "neither found, or non-method" @@ -7433,7 +7433,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) = // do not emit serialization related members if target framework lacks SerializationInfo or StreamingContext match g.iltyp_SerializationInfo, g.iltyp_StreamingContext with | Some serializationInfoType, Some streamingContextType -> - let ilCtorDefForSerialziation = + let ilCtorDefForSerialization = mkILCtor(ILMemberAccess.Family, [mkILParamNamed("info", serializationInfoType);mkILParamNamed("context", streamingContextType)], mkMethodBody @@ -7445,7 +7445,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) = mkNormalCall (mkILCtorMethSpecForTy (g.iltyp_Exception, [serializationInfoType; streamingContextType])) ], None)) - [ilCtorDefForSerialziation] + [ilCtorDefForSerialization] (* let getObjectDataMethodForSerialization = let ilMethodDef = @@ -7469,7 +7469,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) = { ilMethodDef with SecurityDecls=mkILSecurityDecls [ IL.mkPermissionSet g.ilg (ILSecurityAction.Demand, [(securityPermissionAttributeType, [("SerializationFormatter", g.ilg.typ_Bool, ILAttribElem.Bool true)])])] HasSecurity=true } - [ilCtorDefForSerialziation; getObjectDataMethodForSerialization] + [ilCtorDefForSerialization; getObjectDataMethodForSerialization] *) //#endif | _ -> [] @@ -7644,8 +7644,8 @@ let defaultOf = /// Top-level val bindings are stored (for example) in static fields. /// In the FSI case, these fields are be created and initialised, so we can recover the object. /// IlxGen knows how v was stored, and then ilreflect knows how this storage was generated. -/// IlxGen converts (v: Tast.Val) to AbsIL datastructures. -/// Ilreflect converts from AbsIL datastructures to emitted Type, FieldInfo, MethodInfo etc. +/// IlxGen converts (v: Tast.Val) to AbsIL data structures. +/// Ilreflect converts from AbsIL data structures to emitted Type, FieldInfo, MethodInfo etc. let LookupGeneratedValue (amap: ImportMap) (ctxt: ExecutionContext) eenv (v: Val) = try // Convert the v.Type into a System.Type according to ilxgen and ilreflect. diff --git a/src/fsharp/InfoReader.fs b/src/fsharp/InfoReader.fs index 7e9dffdd52b..c36847d9e3d 100644 --- a/src/fsharp/InfoReader.fs +++ b/src/fsharp/InfoReader.fs @@ -299,10 +299,10 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) = let GetIntrinsicRecdOrClassFieldInfosUncached ((optFilter, ad), m, ty) = FoldPrimaryHierarchyOfType (fun ty acc -> GetImmediateIntrinsicRecdOrClassFieldsOfType (optFilter, ad) m ty @ acc) g amap m AllowMultiIntfInstantiations.Yes ty [] - let GetEntireTypeHierachyUncached (allowMultiIntfInst, m, ty) = + let GetEntireTypeHierarchyUncached (allowMultiIntfInst, m, ty) = FoldEntireHierarchyOfType (fun ty acc -> ty :: acc) g amap m allowMultiIntfInst ty [] - let GetPrimaryTypeHierachyUncached (allowMultiIntfInst, m, ty) = + let GetPrimaryTypeHierarchyUncached (allowMultiIntfInst, m, ty) = FoldPrimaryHierarchyOfType (fun ty acc -> ty :: acc) g amap m allowMultiIntfInst ty [] /// The primitive reader for the named items up a hierarchy @@ -385,8 +385,8 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) = let eventInfoCache = MakeInfoCache GetIntrinsicEventInfosUncached hashFlags1 let namedItemsCache = MakeInfoCache GetIntrinsicNamedItemsUncached hashFlags2 - let entireTypeHierarchyCache = MakeInfoCache GetEntireTypeHierachyUncached HashIdentity.Structural - let primaryTypeHierarchyCache = MakeInfoCache GetPrimaryTypeHierachyUncached HashIdentity.Structural + let entireTypeHierarchyCache = MakeInfoCache GetEntireTypeHierarchyUncached HashIdentity.Structural + let primaryTypeHierarchyCache = MakeInfoCache GetPrimaryTypeHierarchyUncached HashIdentity.Structural member x.g = g member x.amap = amap @@ -434,11 +434,11 @@ type InfoReader(g: TcGlobals, amap: Import.ImportMap) = namedItemsCache.Apply(((nm, ad), m, ty)) /// Get the super-types of a type, including interface types. - member x.GetEntireTypeHierachy (allowMultiIntfInst, m, ty) = + member x.GetEntireTypeHierarchy (allowMultiIntfInst, m, ty) = entireTypeHierarchyCache.Apply((allowMultiIntfInst, m, ty)) /// Get the super-types of a type, excluding interface types. - member x.GetPrimaryTypeHierachy (allowMultiIntfInst, m, ty) = + member x.GetPrimaryTypeHierarchy (allowMultiIntfInst, m, ty) = primaryTypeHierarchyCache.Apply((allowMultiIntfInst, m, ty)) diff --git a/src/fsharp/InnerLambdasToTopLevelFuncs.fs b/src/fsharp/InnerLambdasToTopLevelFuncs.fs index fabd5583c23..5ced353f396 100644 --- a/src/fsharp/InnerLambdasToTopLevelFuncs.fs +++ b/src/fsharp/InnerLambdasToTopLevelFuncs.fs @@ -743,7 +743,7 @@ let FlatEnvPacks g fclassM topValS declist (reqdItemsMap: Zmap List.tryFind (IsGenericValWithGenericContraints g) with + match vals |> List.tryFind (IsGenericValWithGenericConstraints g) with | None -> () | Some v -> raise (AbortTLR v.Range) @@ -813,7 +813,7 @@ let DumpEnvPackM g envPackM = /// e.g. deciding whether to tuple up the environment or not. /// e.g. deciding whether to use known values for required sub environments. /// -/// Scope for optimisating env packing here. +/// Scope for optimization env packing here. /// For now, pass all environments via arguments since aiming to eliminate allocations. /// Later, package as tuples if arg lists get too long. let ChooseReqdItemPackings g fclassM topValS declist reqdItemsMap = diff --git a/src/fsharp/InternalCollections.fs b/src/fsharp/InternalCollections.fs index eda256e715c..d2a15bd841b 100755 --- a/src/fsharp/InternalCollections.fs +++ b/src/fsharp/InternalCollections.fs @@ -84,18 +84,18 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro | true, value -> yield key, value ] #endif - let AssignWithStrength(tok,newdata,discard1) = - let actualLength = List.length newdata + let AssignWithStrength(tok,newData,discard1) = + let actualLength = List.length newData let tossThreshold = max 0 (actualLength - keepMax) // Delete everything less than this threshold - let weakThreshhold = max 0 (actualLength - keepStrongly) // Weaken everything less than this threshold + let weakThreshold = max 0 (actualLength - keepStrongly) // Weaken everything less than this threshold - let newdata = newdata|> List.mapi( fun n kv -> n,kv ) // Place the index. - let newdata,discard2 = newdata |> List.partition (fun (n:int,v) -> n >= tossThreshold || requiredToKeep (snd v)) - let newdata = - newdata + let newData = newData|> List.mapi( fun n kv -> n,kv ) // Place the index. + let newData,discard2 = newData |> List.partition (fun (n:int,v) -> n >= tossThreshold || requiredToKeep (snd v)) + let newData = + newData |> List.map( fun (n:int,(k,v)) -> let handle = - if n(keepStro Strong(v) k,handle ) ignore tok // Updating refs requires tok - refs <- newdata + refs <- newData discard1 |> List.iter (snd >> strongDiscard) discard2 |> List.iter (snd >> snd >> strongDiscard) @@ -117,14 +117,14 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro member al.TryGetKeyValue(tok, key) = let data = FilterAndHold(tok) - let result,newdata = TryGetKeyValueImpl(data,key) - AssignWithStrength(tok,newdata,[]) + let result,newData = TryGetKeyValueImpl(data,key) + AssignWithStrength(tok,newData,[]) result member al.TryGet(tok, key) = let data = FilterAndHold(tok) - let result,newdata = TryGetKeyValueImpl(data,key) - AssignWithStrength(tok,newdata,[]) + let result,newData = TryGetKeyValueImpl(data,key) + AssignWithStrength(tok,newData,[]) match result with | Some(_,value) -> Some(value) | None -> None @@ -137,8 +137,8 @@ type internal AgedLookup<'Token, 'Key, 'Value when 'Value : not struct>(keepStro member al.Remove(tok, key) = let data = FilterAndHold(tok) - let newdata,discard = RemoveImpl (data,key) - AssignWithStrength(tok,newdata,discard) + let newData,discard = RemoveImpl (data,key) + AssignWithStrength(tok,newData,discard) member al.Clear(tok) = let discards = FilterAndHold(tok) diff --git a/src/fsharp/LanguageFeatures.fs b/src/fsharp/LanguageFeatures.fs index 2f4e44940c9..8f6a873e206 100644 --- a/src/fsharp/LanguageFeatures.fs +++ b/src/fsharp/LanguageFeatures.fs @@ -95,4 +95,4 @@ type LanguageVersion (specifiedVersion) = |] /// Get the specified LanguageVersion - member __.SpecifiedVerson = specified + member __.SpecifiedVersion = specified diff --git a/src/fsharp/LanguageFeatures.fsi b/src/fsharp/LanguageFeatures.fsi index d1d190d3f96..2b42698dd06 100644 --- a/src/fsharp/LanguageFeatures.fsi +++ b/src/fsharp/LanguageFeatures.fsi @@ -36,4 +36,4 @@ type LanguageVersion = member ValidOptions: string array /// Get the specified LanguageVersion - member SpecifiedVerson: decimal + member SpecifiedVersion: decimal diff --git a/src/fsharp/LexFilter.fs b/src/fsharp/LexFilter.fs index e37b0c35b1b..22dd4c49362 100755 --- a/src/fsharp/LexFilter.fs +++ b/src/fsharp/LexFilter.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. /// LexFilter - process the token stream prior to parsing. -/// Implements the offside rule and a copule of other lexical transformations. +/// Implements the offside rule and a couple of other lexical transformations. module internal FSharp.Compiler.LexFilter open Internal.Utilities.Text.Lexing @@ -630,15 +630,15 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, //-------------------------------------------------------------------------- let pushCtxt tokenTup (newCtxt: Context) = - let rec unindentationLimit strict stack = + let rec undentationLimit strict stack = match newCtxt, stack with | _, [] -> PositionWithColumn(newCtxt.StartPos, -1) // ignore Vanilla because a SeqBlock is always coming - | _, (CtxtVanilla _ :: rest) -> unindentationLimit strict rest + | _, (CtxtVanilla _ :: rest) -> undentationLimit strict rest - | _, (CtxtSeqBlock _ :: rest) when not strict -> unindentationLimit strict rest - | _, (CtxtParen _ :: rest) when not strict -> unindentationLimit strict rest + | _, (CtxtSeqBlock _ :: rest) when not strict -> undentationLimit strict rest + | _, (CtxtParen _ :: rest) when not strict -> undentationLimit strict rest // 'begin match' limited by minimum of two // '(match' limited by minimum of two @@ -658,7 +658,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // Otherwise 'function ...' places no limit until we hit a CtxtLetDecl etc... (Recursive) | (CtxtMatchClauses _), (CtxtFunction _ :: rest) - -> unindentationLimit false rest + -> undentationLimit false rest // 'try ... with' limited by 'try' | _, (CtxtMatchClauses _ :: (CtxtTry _ as limitCtxt) :: _rest) @@ -666,7 +666,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // 'fun ->' places no limit until we hit a CtxtLetDecl etc... (Recursive) | _, (CtxtFun _ :: rest) - -> unindentationLimit false rest + -> undentationLimit false rest // 'f ...{' places no limit until we hit a CtxtLetDecl etc... // 'f ...[' places no limit until we hit a CtxtLetDecl etc... @@ -674,7 +674,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, | _, (CtxtParen ((LBRACE | LBRACK | LBRACK_BAR), _) :: CtxtSeqBlock _ :: rest) | _, (CtxtParen ((LBRACE | LBRACK | LBRACK_BAR), _) :: CtxtVanilla _ :: CtxtSeqBlock _ :: rest) | _, (CtxtSeqBlock _ :: CtxtParen((LBRACE | LBRACK | LBRACK_BAR), _) :: CtxtVanilla _ :: CtxtSeqBlock _ :: rest) - -> unindentationLimit false rest + -> undentationLimit false rest // MAJOR PERMITTED UNDENTATION This is allowing: // if x then y else @@ -696,7 +696,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, | CtxtWithAsAugment _, ((CtxtInterfaceHead _ | CtxtMemberHead _ | CtxtException _ | CtxtTypeDefns _) as limitCtxt :: _rest) -> PositionWithColumn(limitCtxt.StartPos, limitCtxt.StartCol) - // Permit unindentation via parentheses (or begin/end) following a 'then', 'else' or 'do': + // Permit undentation via parentheses (or begin/end) following a 'then', 'else' or 'do': // if nr > 0 then ( // nr <- nr - 1 // acc <- d @@ -719,7 +719,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // end | _, ((CtxtWithAsAugment _ | CtxtThen _ | CtxtElse _ | CtxtDo _ ) :: rest) - -> unindentationLimit false rest + -> undentationLimit false rest // '... (function ->' places no limit until we hit a CtxtLetDecl etc.... (Recursive) @@ -737,7 +737,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // 0 // | 2 -> ... <---- not allowed | _, (CtxtFunction _ :: rest) - -> unindentationLimit false rest + -> undentationLimit false rest // 'module ... : sig' limited by 'module' // 'module ... : struct' limited by 'module' @@ -811,7 +811,7 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // always already pushed a SeqBlock at this position. | CtxtVanilla _ -> () | _ -> - let p1 = unindentationLimit true offsideStack + let p1 = undentationLimit true offsideStack let c2 = newCtxt.StartCol if c2 < p1.Column then warn tokenTup @@ -2161,8 +2161,8 @@ type LexFilterImpl (lightSyntaxStatus: LightSyntaxStatus, compilingFsLib, lexer, // Split this token to allow "1..2" for range specification | INT32_DOT_DOT (i, v) -> - let dotdotPos = new LexbufState(tokenTup.EndPos.ShiftColumnBy(-2), tokenTup.EndPos, false) - delayToken(new TokenTup(DOT_DOT, dotdotPos, tokenTup.LastTokenPos)) + let dotDotPos = new LexbufState(tokenTup.EndPos.ShiftColumnBy(-2), tokenTup.EndPos, false) + delayToken(new TokenTup(DOT_DOT, dotDotPos, tokenTup.LastTokenPos)) delayToken(tokenTup.UseShiftedLocation(INT32(i, v), 0, -2)) true // Split @>. and @@>. into two diff --git a/src/fsharp/LowerCallsAndSeqs.fs b/src/fsharp/LowerCallsAndSeqs.fs index 6bc583faae1..f40fcf8dec1 100644 --- a/src/fsharp/LowerCallsAndSeqs.fs +++ b/src/fsharp/LowerCallsAndSeqs.fs @@ -89,7 +89,7 @@ type LoweredSeqFirstPhaseResult = /// that holds the "goto" destination for a tailcalling sequence expression /// 'pcMap' is the mapping from code labels to values for 'pc' /// - /// The phase2 function returns the core of the generate, dipsose and checkDispose implementations. + /// The phase2 function returns the core of the generate, dispose and checkDispose implementations. phase2 : ((* pc: *) ValRef * (* current: *) ValRef * (* nextVar: *) ValRef * Map -> Expr * Expr * Expr) /// The labels allocated for one portion of the sequence expression @@ -434,7 +434,7 @@ let LowerSeqExpr g amap overallExpr = | Expr.Let (bind, bodyExpr, m, _) // Restriction: compilation of sequence expressions containing non-toplevel constrained generic functions is not supported - when bind.Var.IsCompiledAsTopLevel || not (IsGenericValWithGenericContraints g bind.Var) -> + when bind.Var.IsCompiledAsTopLevel || not (IsGenericValWithGenericConstraints g bind.Var) -> let resBody = Lower false isTailCall noDisposeContinuationLabel currentDisposeContinuationLabel bodyExpr match resBody with @@ -671,7 +671,7 @@ let LowerSeqExpr g amap overallExpr = // ``disposalExpr`` // with e -> exn <- e // if exn <> null then raise exn - let handleExeceptionsInDispose disposalExpr = + let handleExceptionsInDispose disposalExpr = let exnV, exnE = mkMutableCompGenLocal m "exn" g.exn_ty let exnVref = mkLocalValRef exnV let startLabel = IL.generateCodeLabel() @@ -738,11 +738,11 @@ let LowerSeqExpr g amap overallExpr = NoSequencePointAtLetBinding m exnV (Expr.Const (Const.Zero, m, g.exn_ty)) (mkCompGenSequential m whileLoop doRaise) - // Add the jumptable to the GenerateNext method + // Add the jump table to the GenerateNext method let generateExprWithJumpTable = addJumpTable false generateExprWithCleanup - // Add the jumptable to the Dispose method + // Add the jump table to the Dispose method let disposalExprWithJumpTable = if res.significantClose then let disposalExpr = @@ -757,11 +757,11 @@ let LowerSeqExpr g amap overallExpr = (mkValSet m currVarRef (mkDefault (m, currVarRef.Type))))) disposalExpr |> addJumpTable true - |> handleExeceptionsInDispose + |> handleExceptionsInDispose else mkValSet m pcVarRef (mkInt32 g m pcDone) - // Add the jumptable to the CheckDispose method + // Add the jump table to the CheckDispose method let checkDisposeExprWithJumpTable = addJumpTable true checkDisposeExprWithCleanup diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index cf590b69ee3..fdae67c6ad5 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -1139,7 +1139,7 @@ let BuildMethodCall tcVal g amap isMutable m isProp minfo valUseFlags minst objA if minfo.IsClassConstructor then error (InternalError (minfo.LogicalName + ": cannot call a class constructor", m)) let useCallvirt = not valu && not direct && minfo.IsVirtual - let isProtected = minfo.IsProtectedAccessiblity + let isProtected = minfo.IsProtectedAccessibility let exprTy = if isCtor then enclTy else minfo.GetFSharpReturnTy(amap, m, minst) match TryImportProvidedMethodBaseAsLibraryIntrinsic (amap, m, providedMeth) with | Some fsValRef -> @@ -1339,7 +1339,7 @@ module ProvidedMethodCalls = | None -> match ea.PApplyOption((function ProvidedNewTupleExpr x -> Some x | _ -> None), m) with | Some info -> - let elems = info.PApplyArray(id, "GetInvokerExpresson", m) + let elems = info.PApplyArray(id, "GetInvokerExpression", m) let elemsT = elems |> Array.map exprToExpr |> Array.toList let exprT = mkRefTupledNoTypes g m elemsT None, (exprT, tyOfExpr g exprT) @@ -1348,7 +1348,7 @@ module ProvidedMethodCalls = | Some info -> let ty, elems = info.PApply2(id, m) let tyT = Import.ImportProvidedType amap m ty - let elems = elems.PApplyArray(id, "GetInvokerExpresson", m) + let elems = elems.PApplyArray(id, "GetInvokerExpression", m) let elemsT = elems |> Array.map exprToExpr |> Array.toList let exprT = Expr.Op (TOp.Array, [tyT], elemsT, m) None, (exprT, tyOfExpr g exprT) @@ -1419,7 +1419,7 @@ module ProvidedMethodCalls = | Some info -> let delegateTy, boundVars, delegateBodyExpr = info.PApply3(id, m) let delegateTyT = Import.ImportProvidedType amap m delegateTy - let vs = boundVars.PApplyArray(id, "GetInvokerExpresson", m) |> Array.toList + let vs = boundVars.PApplyArray(id, "GetInvokerExpression", m) |> Array.toList let vsT = List.map addVar vs let delegateBodyExprT = exprToExpr delegateBodyExpr List.iter removeVar vs @@ -1489,7 +1489,7 @@ module ProvidedMethodCalls = let (ctor, args) = ne.PApply2(id, m) let targetMethInfo = ProvidedMeth(amap, ctor.PApply((fun ne -> upcast ne), m), None, m) let objArgs = [] - let arguments = [ for ea in args.PApplyArray(id, "GetInvokerExpresson", m) -> exprToExpr ea ] + let arguments = [ for ea in args.PApplyArray(id, "GetInvokerExpression", m) -> exprToExpr ea ] let callExpr = BuildMethodCall tcVal g amap Mutates.PossiblyMutates m false targetMethInfo isSuperInit [] objArgs arguments callExpr @@ -1514,7 +1514,7 @@ module ProvidedMethodCalls = | None -> [] | Some objExpr -> [exprToExpr objExpr] - let arguments = [ for ea in args.PApplyArray(id, "GetInvokerExpresson", m) -> exprToExpr ea ] + let arguments = [ for ea in args.PApplyArray(id, "GetInvokerExpression", m) -> exprToExpr ea ] let genericArguments = if meth.PUntaint((fun m -> m.IsGenericMethod), m) then meth.PApplyArray((fun m -> m.GetGenericArguments()), "GetGenericArguments", m) diff --git a/src/fsharp/NameResolution.fs b/src/fsharp/NameResolution.fs index 9715905d3c8..389c6e16b04 100644 --- a/src/fsharp/NameResolution.fs +++ b/src/fsharp/NameResolution.fs @@ -534,7 +534,7 @@ let ExtensionPropInfosOfTypeInScope collectionSettings (infoReader:InfoReader) ( extMemsDangling else let extMemsFromHierarchy = - infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes, m, ty) + infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> if isAppTy g ty then let tcref = tcrefOfAppTy g ty @@ -598,7 +598,7 @@ let ExtensionMethInfosOfTypeInScope (collectionSettings:ResultCollectionSettings extMemsDangling else let extMemsFromHierarchy = - infoReader.GetEntireTypeHierachy(AllowMultiIntfInstantiations.Yes, m, ty) + infoReader.GetEntireTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> let g = infoReader.g if isAppTy g ty then @@ -654,11 +654,11 @@ let AddValRefToExtensionMembers pri (eIndexedExtensionMembers: TyconRefMultiMap< eIndexedExtensionMembers -/// This entrypoint is used to add some extra items to the environment for Visual Studio, e.g. static members +/// This entry point is used to add some extra items to the environment for Visual Studio, e.g. static members let AddFakeNamedValRefToNameEnv nm nenv vref = {nenv with eUnqualifiedItems = nenv.eUnqualifiedItems.Add (nm, Item.Value vref) } -/// This entrypoint is used to add some extra items to the environment for Visual Studio, e.g. record members +/// This entry point is used to add some extra items to the environment for Visual Studio, e.g. record members let AddFakeNameToNameEnv nm nenv item = {nenv with eUnqualifiedItems = nenv.eUnqualifiedItems.Add (nm, item) } @@ -1351,7 +1351,7 @@ let MakeNestedType (ncenv: NameResolver) (tinst: TType list) m (tcrefNested: Tyc /// Get all the accessible nested types of an existing type. let GetNestedTypesOfType (ad, ncenv: NameResolver, optFilter, staticResInfo, checkForGenerated, m) ty = let g = ncenv.g - ncenv.InfoReader.GetPrimaryTypeHierachy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> + ncenv.InfoReader.GetPrimaryTypeHierarchy(AllowMultiIntfInstantiations.Yes, m, ty) |> List.collect (fun ty -> match ty with | AppTy g (tcref, tinst) -> let tycon = tcref.Deref @@ -1610,7 +1610,7 @@ let ItemsAreEffectivelyEqual g orig other = name1 = name2 && tyconRefDefnEq g tcref1 tcref2 | EventUse evt1, EventUse evt2 -> - EventInfo.EventInfosUseIdenticalDefintions evt1 evt2 || + EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2 || // Allow for equality up to signature matching match evt1.ArbitraryValRef, evt2.ArbitraryValRef with | Some vref1, Some vref2 -> valRefDefnEq g vref1 vref2 @@ -3282,8 +3282,8 @@ let FreshenRecdFieldRef (ncenv: NameResolver) m (rfref: RecdFieldRef) = // QUERY (instantiationGenerator cleanup): it would be really nice not to flow instantiationGenerator to here. let private ResolveExprDotLongIdent (ncenv: NameResolver) m ad nenv ty (id: Ident) rest findFlag = let typeNameResInfo = TypeNameResolutionInfo.Default - let adhoctDotSearchAccessible = AtMostOneResult m (ResolveLongIdentInTypePrim ncenv nenv LookupKind.Expr ResolutionInfo.Empty 1 m ad id rest findFlag typeNameResInfo ty) - match adhoctDotSearchAccessible with + let adhocDotSearchAccessible = AtMostOneResult m (ResolveLongIdentInTypePrim ncenv nenv LookupKind.Expr ResolutionInfo.Empty 1 m ad id rest findFlag typeNameResInfo ty) + match adhocDotSearchAccessible with | Exception _ -> // If the dot is not resolved by adhoc overloading then look for a record field // that can resolve the name. @@ -3306,7 +3306,7 @@ let private ResolveExprDotLongIdent (ncenv: NameResolver) m ad nenv ty (id: Iden |> AtMostOneResult m |> ForceRaise | _ -> - ForceRaise adhoctDotSearchAccessible + ForceRaise adhocDotSearchAccessible let ComputeItemRange wholem (lid: Ident list) rest = match rest with @@ -4103,7 +4103,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE | _ -> [], false | _ -> [], false) - let staticSometingInType = + let staticSomethingInType = [ if not isItemVal then // type.lookup: lookup a static something in a type for tcref in LookupTypeNameInEnvNoArity OpenQualified id nenv do @@ -4111,7 +4111,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE let ty = FreshenTycon ncenv m tcref yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty ] - namespaces @ values @ staticSometingInType + namespaces @ values @ staticSomethingInType /// Resolve a (possibly incomplete) long identifier to a set of possible resolutions. let ResolvePartialLongIdent ncenv nenv isApplicableMeth m ad plid allowObsolete = diff --git a/src/fsharp/NameResolution.fsi b/src/fsharp/NameResolution.fsi index a1567ed43bf..ea3bbd8aeaf 100755 --- a/src/fsharp/NameResolution.fsi +++ b/src/fsharp/NameResolution.fsi @@ -328,7 +328,7 @@ type internal TcSymbolUses = /// Represents open declaration statement. type internal OpenDeclaration = - { /// Long identifier as it's presented in soruce code. + { /// Long identifier as it's presented in source code. LongId: Ident list /// Full range of the open declaration. diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index 2d9ea197db4..6479d6c6729 100644 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -47,10 +47,10 @@ module internal PrintUtilities = isEnumTy g ty || isDelegateTy g ty || ExistsHeadTypeInEntireHierarchy g amap m ty g.exn_tcr || ExistsHeadTypeInEntireHierarchy g amap m ty g.tcref_System_Attribute - let applyMaxMembers maxMembers (alldecls: _ list) = + let applyMaxMembers maxMembers (allDecls: _ list) = match maxMembers with - | Some n when alldecls.Length > n -> (alldecls |> List.truncate n) @ [wordL (tagPunctuation "...")] - | _ -> alldecls + | Some n when allDecls.Length > n -> (allDecls |> List.truncate n) @ [wordL (tagPunctuation "...")] + | _ -> allDecls /// fix up a name coming from IL metadata by quoting "funny" names (keywords, otherwise invalid identifiers) let adjustILName n = @@ -185,12 +185,12 @@ module private PrintIL = | ILType.Modified (_, _, t) -> layoutILType denv ilTyparSubst t // Just recurse through them to the contained ILType /// Layout a function pointer signature using type-only-F#-style. No argument names are printed. - and private layoutILCallingSignature denv ilTyparSubst cons (signatur: ILCallingSignature) = + and private layoutILCallingSignature denv ilTyparSubst cons (signature: ILCallingSignature) = // We need a special case for // constructors (Their return types are reported as `void`, but this is // incorrect; so if we're dealing with a constructor we require that the // return type be passed along as the `cons` parameter.) - let args = signatur.ArgTypes |> List.map (layoutILType denv ilTyparSubst) + let args = signature.ArgTypes |> List.map (layoutILType denv ilTyparSubst) let res = match cons with | Some className -> @@ -198,7 +198,7 @@ module private PrintIL = // special case for constructor return-type (viz., the class itself) layoutILTypeRefName denv names ^^ (pruneParams className ilTyparSubst |> paramsL) | None -> - signatur.ReturnType |> layoutILType denv ilTyparSubst + signature.ReturnType |> layoutILType denv ilTyparSubst match args with | [] -> WordL.structUnit ^^ WordL.arrow ^^ res @@ -566,7 +566,7 @@ module private PrintTypes = | Const.String bs -> "\"" + bs + "\"" |> tagNumericLiteral | Const.Unit -> "()" |> tagPunctuation | Const.Decimal bs -> string bs + "M" |> tagNumericLiteral - // either "null" or "the defaut value for a struct" + // either "null" or "the default value for a struct" | Const.Zero -> tagKeyword(if isRefTy g ty then "null" else "default") wordL str @@ -1788,14 +1788,14 @@ module private TastDefinitionPrinting = tycon.TrueFieldsAsList |> List.filter (fun f -> not f.IsStatic) |> List.map (fun f -> WordL.keywordVal ^^ layoutRecdField true denv f) - let alldecls = inherits @ memberImplementLs @ memberCtorLs @ instanceValsLs @ vsprs @ memberInstanceLs @ staticValsLs @ memberStaticLs - if isNil alldecls then + let allDecls = inherits @ memberImplementLs @ memberCtorLs @ instanceValsLs @ vsprs @ memberInstanceLs @ staticValsLs @ memberStaticLs + if isNil allDecls then None else - let alldecls = applyMaxMembers denv.maxMembers alldecls - let emptyMeasure = match tycon.TypeOrMeasureKind with TyparKind.Measure -> isNil alldecls | _ -> false + let allDecls = applyMaxMembers denv.maxMembers allDecls + let emptyMeasure = match tycon.TypeOrMeasureKind with TyparKind.Measure -> isNil allDecls | _ -> false if emptyMeasure then None else - let declsL = aboveListL alldecls + let declsL = aboveListL allDecls let declsL = match start with Some s -> (wordL s @@-- declsL) @@ wordL (tagKeyword "end") | None -> declsL Some declsL | TUnionRepr _ -> diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index e89f3e4284b..69b7d640a71 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -100,7 +100,7 @@ type ExprValueInfo = /// arities: The number of bunches of untupled args and type args, and /// the number of args in each bunch. NOTE: This include type arguments. /// expr: The value, a lambda term. - /// ty: The type of lamba term + /// ty: The type of lambda term | CurriedLambdaValue of Unique * int * int * Expr * TType /// ConstExprValue(size, value) @@ -350,14 +350,14 @@ type OptimizationSettings = member x.EliminateTupleFieldGet () = x.localOpt () - member x.EliminatUnionCaseFieldGet () = x.localOpt () + member x.EliminateUnionCaseFieldGet () = x.localOpt () /// eliminate non-compiler generated immediate bindings member x.EliminateImmediatelyConsumedLocals() = x.localOpt () /// expand "let x = (exp1, exp2, ...)" bindings as prior tmps /// expand "let x = Some exp1" bindings as prior tmps - member x.ExpandStructrualValues() = x.localOpt () + member x.ExpandStructuralValues() = x.localOpt () type cenv = { g: TcGlobals @@ -1132,7 +1132,7 @@ let AbstractOptimizationInfoToEssentials = /// Hide information because of a "let ... in ..." or "let rec ... in ... " let AbstractExprInfoByVars (boundVars: Val list, boundTyVars) ivalue = // Module and member bindings can be skipped when checking abstraction, since abstraction of these values has already been done when - // we hit the end of the module and called AbstractLazyModulInfoByHiding. If we don't skip these then we end up quadtratically retraversing + // we hit the end of the module and called AbstractLazyModulInfoByHiding. If we don't skip these then we end up quadratically retraversing // the inferred optimization data, i.e. at each binding all the way up a sequences of 'lets' in a module. let boundVars = boundVars |> List.filter (fun v -> not v.IsMemberOrModuleBinding) @@ -1524,7 +1524,7 @@ and RewriteBoolLogicCase data (TCase(test, tree)) = TCase(test, RewriteBoolLogicTree data tree) /// Repeatedly combine switch-over-match decision trees, see https://github.com/Microsoft/visualfsharp/issues/635. -/// The outer decision tree is doing a swithc over a boolean result, the inner match is producing only +/// The outer decision tree is doing a switch over a boolean result, the inner match is producing only /// constant boolean results in its targets. let rec CombineBoolLogic expr = @@ -1576,7 +1576,7 @@ let MakeStructuralBindingTemp (v: Val) i (arg: Expr) argTy = ve, mkCompGenBind v arg let ExpandStructuralBindingRaw cenv expr = - assert cenv.settings.ExpandStructrualValues() + assert cenv.settings.ExpandStructuralValues() match expr with | Expr.Let (TBind(v, rhs, tgtSeqPtOpt), body, m, _) when (isRefTupleExpr rhs && @@ -1611,7 +1611,7 @@ let rec RearrangeTupleBindings expr fin = | _ -> None let ExpandStructuralBinding cenv expr = - assert cenv.settings.ExpandStructrualValues() + assert cenv.settings.ExpandStructuralValues() match expr with | Expr.Let (TBind(v, rhs, tgtSeqPtOpt), body, m, _) when (isRefTupleTy cenv.g v.Type && @@ -1708,7 +1708,7 @@ let (|AnyQueryBuilderOpTrans|_|) g = function // | query.For(, ) --> IQueryable if qexprInner is IQueryable, otherwise seq { qexprInner' } // | query.Yield --> not IQueryable, seq { } // | query.YieldFrom --> not IQueryable, seq { yield! } -// | query.Op(, ) --> IQueryable if qexprOuter is IQueryable, otherwise query.Op(qexpOuter', ) +// | query.Op(, ) --> IQueryable if qexprOuter is IQueryable, otherwise query.Op(qexprOuter', ) let rec tryRewriteToSeqCombinators g (e: Expr) = let m = e.Range match e with @@ -2112,7 +2112,7 @@ and OptimizeExprOpReductionsAfter cenv env (op, tyargs, argsR, arginfos, m) = | None -> OptimizeExprOpFallback cenv env (op, tyargs, argsR, m) arginfos UnknownValue and OptimizeExprOpFallback cenv env (op, tyargs, argsR, m) arginfos valu = - // The generic case - we may collect information, but the construction/projection doesnRt disappear + // The generic case - we may collect information, but the construction/projection doesn't disappear let argsTSize = AddTotalSizes arginfos let argsFSize = AddFunctionSizes arginfos let argEffects = OrEffects arginfos @@ -2230,7 +2230,7 @@ and TryOptimizeTupleFieldGet cenv _env (_tupInfo, e1info, tys, n, m) = and TryOptimizeUnionCaseGet cenv _env (e1info, cspec, _tys, n, m) = match e1info.Info with - | StripUnionCaseValue(cspec2, args) when cenv.settings.EliminatUnionCaseFieldGet() && not e1info.HasEffect && cenv.g.unionCaseRefEq cspec cspec2 -> + | StripUnionCaseValue(cspec2, args) when cenv.settings.EliminateUnionCaseFieldGet() && not e1info.HasEffect && cenv.g.unionCaseRefEq cspec cspec2 -> if n >= args.Length then errorR(InternalError( "TryOptimizeUnionCaseGet: term argument out of range", m)) Some args.[n] | _ -> None @@ -2298,7 +2298,7 @@ and OptimizeLinearExpr cenv env expr contf = // Eliminate subsumption coercions for functions. This must be done post-typechecking because we need // complete inference types. let expr = DetectAndOptimizeForExpression cenv.g OptimizeAllForExpressions expr - let expr = if cenv.settings.ExpandStructrualValues() then ExpandStructuralBinding cenv expr else expr + let expr = if cenv.settings.ExpandStructuralValues() then ExpandStructuralBinding cenv expr else expr let expr = stripExpr expr match expr with @@ -2326,7 +2326,7 @@ and OptimizeLinearExpr cenv env expr contf = let (bindR, bindingInfo), env = OptimizeBinding cenv false env bind OptimizeLinearExpr cenv env body (contf << (fun (bodyR, bodyInfo) -> // PERF: This call to ValueIsUsedOrHasEffect/freeInExpr amounts to 9% of all optimization time. - // Is it quadratic or quasi-quadtratic? + // Is it quadratic or quasi-quadratic? if ValueIsUsedOrHasEffect cenv (fun () -> (freeInExpr CollectLocals bodyR).FreeLocals) (bindR, bindingInfo) then // Eliminate let bindings on the way back up let exprR, adjust = TryEliminateLet cenv env bindR bodyR m @@ -3027,7 +3027,7 @@ and ComputeSplitToMethodCondition flag threshold cenv env (e: Expr, einfo) = // None of them should be byrefs not (isByrefLikeTy cenv.g m v.Type) && // None of them should be local polymorphic constrained values - not (IsGenericValWithGenericContraints cenv.g v) && + not (IsGenericValWithGenericConstraints cenv.g v) && // None of them should be mutable not v.IsMutable)))) && not (isByrefLikeTy cenv.g m (tyOfExpr cenv.g e)) diff --git a/src/fsharp/PatternMatchCompilation.fs b/src/fsharp/PatternMatchCompilation.fs index 3b172de1e34..d3c49646c19 100644 --- a/src/fsharp/PatternMatchCompilation.fs +++ b/src/fsharp/PatternMatchCompilation.fs @@ -596,7 +596,7 @@ let rec BuildSwitch inpExprOpt g expr edges dflt m = let testexpr = match discrim with | DecisionTreeTest.ArrayLength(n, _) -> - let _v, vExpr, bind = mkCompGenLocalAndInvisbleBind g "testExpr" m testexpr + let _v, vExpr, bind = mkCompGenLocalAndInvisibleBind g "testExpr" m testexpr mkLetBind m bind (mkLazyAnd g m (mkNonNullTest g m vExpr) (mkILAsmCeq g m (mkLdlen g m vExpr) (mkInt g m n))) | DecisionTreeTest.Const (Const.String _ as c) -> mkCallEqualsOperator g m g.string_ty testexpr (Expr.Const (c, m, g.string_ty)) @@ -952,7 +952,7 @@ let CompilePatternBasic Some vExpr, Some(mkInvisibleBind v appExpr) // Any match on a struct union must take the address of its input. - // We can shortcut the addrof when the original input is a deref of a byref value. + // We can shortcut the addrOf when the original input is a deref of a byref value. | EdgeDiscrim(_i', (DecisionTreeTest.UnionCase (ucref, _)), _) :: _rest when isNil origInputValTypars && ucref.Tycon.IsStructRecordOrUnionTycon -> diff --git a/src/fsharp/PostInferenceChecks.fs b/src/fsharp/PostInferenceChecks.fs index 4d8f05b5a01..c718a94665f 100644 --- a/src/fsharp/PostInferenceChecks.fs +++ b/src/fsharp/PostInferenceChecks.fs @@ -561,7 +561,7 @@ let mkArgsForAppliedVal isBaseCall (vref: ValRef) argsl = | Some topValInfo -> let argArities = topValInfo.AritiesOfArgs let argArities = if isBaseCall && argArities.Length >= 1 then List.tail argArities else argArities - // Check for partial applications: arguments to partial applciations don't get to use byrefs + // Check for partial applications: arguments to partial applications don't get to use byrefs if List.length argsl >= argArities.Length then List.map mkArgsPermit argArities else @@ -640,7 +640,7 @@ let CheckTypePermitSpanLike (cenv: cenv) env m ty = CheckType PermitByRefType.Sp /// Check types occurring in TAST but allow all byrefs. Only used on internally-generated types let CheckTypePermitAllByrefs (cenv: cenv) env m ty = CheckType PermitByRefType.All cenv env m ty -/// Check types ocurring in TAST but disallow inner types to be byref or byref-like types. +/// Check types occurring in TAST but disallow inner types to be byref or byref-like types. let CheckTypeNoInnerByrefs cenv env m ty = CheckType PermitByRefType.NoInnerByRefLike cenv env m ty let CheckTypeInstNoByrefs cenv env m tyargs = @@ -824,7 +824,7 @@ and CheckCallLimitArgs cenv env m returnTy limitArgs (context: PermitByRefExpr) errorR(Error(FSComp.SR.chkNoByrefAddressOfValueFromExpression(), m)) // You cannot call a function that takes a byref of a span-like (not stack referring) and - // either a stack referring spanlike or a local-byref of a stack referring span-like. + // either a stack referring span-like or a local-byref of a stack referring span-like. let isCallLimited = HasLimitFlag LimitFlags.ByRefOfSpanLike limitArgs && (HasLimitFlag LimitFlags.StackReferringSpanLike limitArgs || @@ -1139,7 +1139,7 @@ and CheckExprOp cenv env (op, tyargs, args, m) context expr = let ctorLimitedZoneCheck() = if env.ctorLimitedZone then errorR(Error(FSComp.SR.chkObjCtorsCantUseExceptionHandling(), m)) - // Ensure anonynous record type requirements are recorded + // Ensure anonymous record type requirements are recorded match op with | TOp.AnonRecdGet (anonInfo, _) | TOp.AnonRecd anonInfo -> @@ -1318,7 +1318,7 @@ and CheckExprOp cenv env (op, tyargs, args, m) context expr = // C# applies a rule where the APIs to struct types can't return the addresses of fields in that struct. // There seems no particular reason for this given that other protections in the language, though allowing - // it would mean "readonly" on a struct doesn't imply immutabality-of-contents - it only implies + // it would mean "readonly" on a struct doesn't imply immutability-of-contents - it only implies if context.PermitOnlyReturnable && (match obj with Expr.Val (vref, _, _) -> vref.BaseOrThisInfo = MemberThisVal | _ -> false) && isByrefTy g (tyOfExpr g obj) then errorR(Error(FSComp.SR.chkStructsMayNotReturnAddressesOfContents(), m)) diff --git a/src/fsharp/PrettyNaming.fs b/src/fsharp/PrettyNaming.fs index 4c11b9054d3..13ca5e4fc76 100755 --- a/src/fsharp/PrettyNaming.fs +++ b/src/fsharp/PrettyNaming.fs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. //---------------------------------------------------------------------------- -// Some general F# utilities for mangling / unmangling / manipulating names. +// Some general F# utilities for mangling / demangling / manipulating names. //-------------------------------------------------------------------------- /// Anything to do with special names of identifiers and other lexical rules diff --git a/src/fsharp/SimulatedMSBuildReferenceResolver.fs b/src/fsharp/SimulatedMSBuildReferenceResolver.fs index 8b47ad9bff7..bf5ffc092f0 100644 --- a/src/fsharp/SimulatedMSBuildReferenceResolver.fs +++ b/src/fsharp/SimulatedMSBuildReferenceResolver.fs @@ -138,17 +138,17 @@ let private SimulatedMSBuildResolver = #if !FX_RESHAPED_MSBUILD try - // Seach the GAC on Windows + // Search the GAC on Windows if not found && not isFileName && Environment.OSVersion.Platform = PlatformID.Win32NT then let n = AssemblyName r - let netfx = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() - let gac = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(netfx.TrimEnd('\\'))), "assembly") + let netFx = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() + let gac = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(netFx.TrimEnd('\\'))), "assembly") match n.Version, n.GetPublicKeyToken() with | null, _ | _, null -> let options = [ if Directory.Exists gac then - for gacdir in Directory.EnumerateDirectories gac do - let assemblyDir = Path.Combine(gacdir, n.Name) + for gacDir in Directory.EnumerateDirectories gac do + let assemblyDir = Path.Combine(gacDir, n.Name) if Directory.Exists assemblyDir then for tdir in Directory.EnumerateDirectories assemblyDir do let trialPath = Path.Combine(tdir, qual) @@ -162,18 +162,18 @@ let private SimulatedMSBuildResolver = | v, tok -> if Directory.Exists gac then - for gacdir in Directory.EnumerateDirectories gac do - //printfn "searching GAC directory: %s" gacdir - let assemblyDir = Path.Combine(gacdir, n.Name) + for gacDir in Directory.EnumerateDirectories gac do + //printfn "searching GAC directory: %s" gacDir + let assemblyDir = Path.Combine(gacDir, n.Name) if Directory.Exists assemblyDir then //printfn "searching GAC directory: %s" assemblyDir let tokText = String.concat "" [| for b in tok -> sprintf "%02x" b |] - let verdir = Path.Combine(assemblyDir, "v4.0_"+v.ToString()+"__"+tokText) - //printfn "searching GAC directory: %s" verdir + let verDir = Path.Combine(assemblyDir, "v4.0_"+v.ToString()+"__"+tokText) + //printfn "searching GAC directory: %s" verDir - if Directory.Exists verdir then - let trialPath = Path.Combine(verdir, qual) + if Directory.Exists verDir then + let trialPath = Path.Combine(verDir, qual) //printfn "searching GAC: %s" trialPath if FileSystem.SafeExists trialPath then success trialPath diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 91a63819dab..5ea0d49b52d 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -397,7 +397,7 @@ let mkTyconInst (tycon: Tycon) tinst = mkTyparInst tycon.TyparsNoRange tinst let mkTyconRefInst (tcref: TyconRef) tinst = mkTyconInst tcref.Deref tinst //--------------------------------------------------------------------------- -// Basic equalites +// Basic equalities //--------------------------------------------------------------------------- let tyconRefEq (g: TcGlobals) tcref1 tcref2 = primEntityRefEq g.compilingFslib g.fslibCcu tcref1 tcref2 @@ -721,7 +721,7 @@ let rec stripTyEqnsA g canShortcut ty = | Some abbrevTy -> stripTyEqnsA g canShortcut (applyTyconAbbrev abbrevTy tycon tinst) | None -> - // This is the point where we get to add additional coditional normalizing equations + // This is the point where we get to add additional conditional normalizing equations // into the type system. Such power! // // Add the equation byref<'T> = byref<'T, ByRefKinds.InOut> for when using sufficient FSharp.Core @@ -4282,14 +4282,14 @@ let isPublicTycon (tcref: Tycon) = (tcref.Accessibility = taccessPublic) let freeVarsAllPublic fvs = // Are any non-public items used in the expr (which corresponded to the fvs)? // Recall, taccess occurs in: - // EntityData has ReprAccessibility and Accessiblity + // EntityData has ReprAccessibility and Accessibility // UnionCase has Accessibility // RecdField has Accessibility // ValData has Accessibility // The freevars and FreeTyvars collect local constructs. // Here, we test that all those constructs are public. // - // CODEREVIEW: + // CODE REVIEW: // What about non-local vals. This fix assumes non-local vals must be public. OK? Zset.forall isPublicVal fvs.FreeLocals && Zset.forall isPublicUnionCase fvs.FreeUnionCases && @@ -5748,7 +5748,7 @@ let isExpansiveUnderInstantiation g fty0 tyargs pargs argsl = | _ :: t -> not (isFunTy g fty) || loop (rangeOfFunTy g fty) t loop fty1 argsl) -let rec mkExprApplAux g f fty argsl m = +let rec mkExprAppAux g f fty argsl m = match argsl with | [] -> f | _ -> @@ -5783,7 +5783,7 @@ let rec mkAppsAux g f fty tyargsl argsl m = let arfty = applyForallTy g fty tyargs mkAppsAux g (primMkApp (f, fty) tyargs [] m) arfty rest argsl m | [] -> - mkExprApplAux g f fty argsl m + mkExprAppAux g f fty argsl m let mkApps g ((f, fty), tyargsl, argl, m) = mkAppsAux g f fty tyargsl argl m @@ -6677,7 +6677,7 @@ let mkNil (g: TcGlobals) m ty = mkUnionCaseExpr (g.nil_ucref, [ty], [], m) let mkCons (g: TcGlobals) ty h t = mkUnionCaseExpr (g.cons_ucref, [ty], [h;t], unionRanges h.Range t.Range) -let mkCompGenLocalAndInvisbleBind g nm m e = +let mkCompGenLocalAndInvisibleBind g nm m e = let locv, loce = mkCompGenLocal m nm (tyOfExpr g e) locv, loce, mkInvisibleBind locv e @@ -7230,7 +7230,7 @@ let AdjustArityOfLambdaBody g arity (vs: Val list) body = let MultiLambdaToTupledLambda g vs body = match vs with - | [] -> failwith "MultiLambdaToTupledLambda: expected some argments" + | [] -> failwith "MultiLambdaToTupledLambda: expected some arguments" | [v] -> v, body | vs -> let tupledv, untupler = untupledToRefTupled g vs @@ -7243,7 +7243,7 @@ let (|RefTuple|_|) expr = let MultiLambdaToTupledLambdaIfNeeded g (vs, arg) body = match vs, arg with - | [], _ -> failwith "MultiLambdaToTupledLambda: expected some argments" + | [], _ -> failwith "MultiLambdaToTupledLambda: expected some arguments" | [v], _ -> [(v, arg)], body | vs, RefTuple args when args.Length = vs.Length -> List.zip vs args, body | vs, _ -> @@ -7304,7 +7304,7 @@ let rec MakeApplicationAndBetaReduceAux g (f, fty, tyargsl: TType list list, arg let argvs2, args2 = List.unzip (List.concat pairs) mkLetsBind m (mkCompGenBinds argvs2 args2) body | _ -> - mkExprApplAux g f fty argsl m + mkExprAppAux g f fty argsl m | [] -> f @@ -8526,7 +8526,7 @@ let isCompiledConstraint cx = // Is a value a first-class polymorphic value with .NET constraints? // Used to turn off TLR and method splitting -let IsGenericValWithGenericContraints g (v: Val) = +let IsGenericValWithGenericConstraints g (v: Val) = isForallTy g v.Type && v.Type |> destForallTy g |> fst |> List.exists (fun tp -> List.exists isCompiledConstraint tp.Constraints) diff --git a/src/fsharp/TastOps.fsi b/src/fsharp/TastOps.fsi index 6119007d52c..5179b85239e 100755 --- a/src/fsharp/TastOps.fsi +++ b/src/fsharp/TastOps.fsi @@ -31,7 +31,7 @@ val typeEquiv : TcGlobals -> TType -> TType - /// Check the equivalence of two units-of-measure val measureEquiv : TcGlobals -> Measure -> Measure -> bool -/// Reduce a type to its more anonical form subject to an erasure flag, inference equations and abbreviations +/// Reduce a type to its more canonical form subject to an erasure flag, inference equations and abbreviations val stripTyEqnsWrtErasure: Erasure -> TcGlobals -> TType -> TType /// Build a function type @@ -120,7 +120,7 @@ val mkMutableCompGenLocal : range -> string -> TType -> Val * Expr /// Make a new mutable compiler-generated local value, 'let' bind it to an expression /// 'invisibly' (no sequence point etc.), and build an expression to reference it -val mkCompGenLocalAndInvisbleBind : TcGlobals -> string -> range -> Expr -> Val * Expr * Binding +val mkCompGenLocalAndInvisibleBind : TcGlobals -> string -> range -> Expr -> Val * Expr * Binding /// Build a lambda expression taking multiple values val mkMultiLambda : range -> Val list -> Expr * TType -> Expr @@ -1150,7 +1150,7 @@ type SignatureRepackageInfo = { /// The list of corresponding values RepackagedVals: (ValRef * ValRef) list - /// The list of corresponding modules, namespacea and type definitions + /// The list of corresponding modules, namespaces and type definitions RepackagedEntities: (TyconRef * TyconRef) list } /// The empty table @@ -1219,7 +1219,7 @@ val IsHiddenVal : (Remap * SignatureHidingInfo) list -> Val -> bool /// Determine if a record field is hidden by a signature val IsHiddenRecdField : (Remap * SignatureHidingInfo) list -> RecdFieldRef -> bool -/// Adjust marks in expressions, replacing all marks by thegiven mark. +/// Adjust marks in expressions, replacing all marks by the given mark. /// Used when inlining. val remarkExpr : range -> Expr -> Expr @@ -1250,7 +1250,7 @@ val mkAddrGet : range -> ValRef -> Expr /// &localv val mkValAddr : range -> readonly: bool -> ValRef -> Expr -/// Build an exression representing the read of an instance class or record field. +/// Build an expression representing the read of an instance class or record field. /// First take the address of the record expression if it is a struct. val mkRecdFieldGet : TcGlobals -> Expr * RecdFieldRef * TypeInst * range -> Expr @@ -1280,7 +1280,7 @@ val AdjustArityOfLambdaBody : TcGlobals -> int -> Val list -> Expr -> Val list * /// Make an application expression, doing beta reduction by introducing let-bindings val MakeApplicationAndBetaReduce : TcGlobals -> Expr * TType * TypeInst list * Exprs * range -> Expr -/// COmbine two static-resolution requirements on a type parameter +/// Combine two static-resolution requirements on a type parameter val JoinTyparStaticReq : TyparStaticReq -> TyparStaticReq -> TyparStaticReq /// Layout for internal compiler debugging purposes @@ -1481,10 +1481,10 @@ val destListTy : TcGlobals -> TType -> TType /// Build an array type of the given rank val mkArrayTy : TcGlobals -> int -> TType -> range -> TType -/// Check if a type definition is one of the artifical type definitions used for array types of different ranks +/// Check if a type definition is one of the artificial type definitions used for array types of different ranks val isArrayTyconRef : TcGlobals -> TyconRef -> bool -/// Determine the rank of one of the artifical type definitions used for array types +/// Determine the rank of one of the artificial type definitions used for array types val rankOfArrayTyconRef : TcGlobals -> TyconRef -> int /// Determine if a type is the F# unit type @@ -2218,7 +2218,7 @@ val RewriteExpr : ExprRewritingEnv -> Expr -> Expr val RewriteImplFile : ExprRewritingEnv -> TypedImplFile -> TypedImplFile -val IsGenericValWithGenericContraints: TcGlobals -> Val -> bool +val IsGenericValWithGenericConstraints: TcGlobals -> Val -> bool type Entity with diff --git a/src/fsharp/TastPickle.fs b/src/fsharp/TastPickle.fs index da6906cf33c..92f4f1a5b8d 100644 --- a/src/fsharp/TastPickle.fs +++ b/src/fsharp/TastPickle.fs @@ -1368,7 +1368,7 @@ let p_tys = (p_list p_ty) let fill_p_attribs, p_attribs = p_hole() // In F# 4.5, the type of the "this" pointer for structs is considered to be inref for the purposes of checking the implementation -// of the struct. However for backwards compat reaons we can't serialize this as the type. +// of the struct. However for backwards compat reasons we can't serialize this as the type. let checkForInRefStructThisArg st ty = let g = st.oglobals let _, tauTy = tryDestForallTy g ty @@ -2163,7 +2163,7 @@ and u_entity_spec_data st : Entity = entity_xmldoc= defaultArg x15 XmlDoc.Empty entity_xmldocsig = System.String.Empty entity_tycon_abbrev = x8 - entity_accessiblity = x4a + entity_accessibility = x4a entity_tycon_repr_accessibility = x4b entity_exn_info = x14 } } diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 5cc848e5ab1..4181cb846ce 100644 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -286,7 +286,7 @@ let addFreeItemOfTy ty eUngeneralizableItems = if isEmptyFreeTyvars fvs then eUngeneralizableItems else UngeneralizableItem(fun () -> freeInType CollectAllNoCaching ty) :: eUngeneralizableItems -/// Add the contents of a module type to the TcEnv, i.e. register the contants as ungeneralizable. +/// Add the contents of a module type to the TcEnv, i.e. register the contents as ungeneralizable. /// Add a module type to the TcEnv, i.e. register it as ungeneralizable. let addFreeItemOfModuleTy mtyp eUngeneralizableItems = let fvs = freeInModuleTy mtyp @@ -410,7 +410,7 @@ let AddNonLocalCcu g amap scopem env assemblyName (ccu: CcuThunk, internalsVisib { env with eNameResEnv = AddTyconRefsToNameEnv BulkAdd.Yes false g amap env.eAccessRights scopem true env.eNameResEnv tcrefs } env -/// Adjust the TcEnv to account for a fully processed "namespace" declaration in thie file +/// Adjust the TcEnv to account for a fully processed "namespace" declaration in this file let AddLocalRootModuleOrNamespace tcSink g amap scopem env (mtyp: ModuleOrNamespaceType) = // Compute the top-rooted module or namespace references let modrefs = mtyp.ModuleAndNamespaceDefinitions |> List.map mkLocalModRef @@ -1278,7 +1278,7 @@ let GeneralizedTypeForTypeScheme typeScheme = let (TypeScheme(generalizedTypars, tau)) = typeScheme mkForallTyIfNeeded generalizedTypars tau -/// Create a type scheme for somthing that is not generic +/// Create a type scheme for something that is not generic let NonGenericTypeScheme ty = TypeScheme([], ty) //------------------------------------------------------------------------- @@ -2456,7 +2456,7 @@ type NormalizedBinding = | NormalizedBinding of SynAccess option * SynBindingKind * - bool * (* pesudo/mustinline value? *) + bool * (* pseudo/mustinline value? *) bool * (* mutable *) SynAttribute list * XmlDoc * @@ -3966,10 +3966,10 @@ let EliminateInitializationGraphs // Check the shape of an object constructor and rewrite calls //------------------------------------------------------------------------- -let CheckAndRewriteObjectCtor g env (ctorLambaExpr: Expr) = +let CheckAndRewriteObjectCtor g env (ctorLambdaExpr: Expr) = - let m = ctorLambaExpr.Range - let tps, vsl, body, returnTy = stripTopLambda (ctorLambaExpr, tyOfExpr g ctorLambaExpr) + let m = ctorLambdaExpr.Range + let tps, vsl, body, returnTy = stripTopLambda (ctorLambdaExpr, tyOfExpr g ctorLambdaExpr) // Rewrite legitimate self-construction calls to CtorValUsedAsSelfInit let error (expr: Expr) = @@ -4180,7 +4180,7 @@ type NewSlotsOK = | NoNewSlots -type ImplictlyBoundTyparsAllowed = +type ImplicitlyBoundTyparsAllowed = | NewTyparsOKButWarnIfNotRigid | NewTyparsOK | NoNewTypars @@ -5806,7 +5806,7 @@ and TcExprUndelayed cenv overallTy env tpenv (synExpr: SynExpr) = // LanguageFeatures.ImplicitYield do not require this validation let implicitYieldEnabled = cenv.g.langVersion.SupportsFeature LanguageFeature.ImplicitYield let validateObjectSequenceOrRecordExpression = not implicitYieldEnabled - let validateExpressionWithIfRequiresParenethesis = not implicitYieldEnabled + let validateExpressionWithIfRequiresParenthesis = not implicitYieldEnabled let acceptDeprecatedIfThenExpression = not implicitYieldEnabled match synExpr with @@ -6022,7 +6022,7 @@ and TcExprUndelayed cenv overallTy env tpenv (synExpr: SynExpr) = | SynExpr.CompExpr (_, _, (SimpleSemicolonSequence cenv acceptDeprecatedIfThenExpression elems as body), _) -> match body with | SimpleSemicolonSequence cenv false _ -> () - | _ when validateExpressionWithIfRequiresParenethesis -> errorR(Deprecated(FSComp.SR.tcExpressionWithIfRequiresParenthesis(), m)) + | _ when validateExpressionWithIfRequiresParenthesis -> errorR(Deprecated(FSComp.SR.tcExpressionWithIfRequiresParenthesis(), m)) | _ -> () let replacementExpr = @@ -9314,7 +9314,7 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del -> false - // Propagte the known application structure into function types + // Propagate the known application structure into function types Propagate cenv overallTy env tpenv (MakeApplicableExprNoFlex cenv expr) (tyOfExpr g expr) delayed // Take all simple arguments and process them before applying the constraint. @@ -9700,7 +9700,7 @@ and TcEventValueThen cenv overallTy env tpenv mItem mExprAndItem objDetails (ein | None -> f [] | Some (objExpr, objExprTy) -> mkCompGenLetIn mItem "eventTarget" objExprTy objExpr (fun (_, ve) -> f [ve]) - // Bind the object target expression to make sure we only run its sdie effects once, and to make + // Bind the object target expression to make sure we only run its side effects once, and to make // sure if it's a mutable reference then we dereference it - see FSharp 1.0 bug 942 let expr = bindObjArgs (fun objVars -> @@ -9849,7 +9849,7 @@ and TcMethodApplication // The arguments are passed as if they are curried with arity [numberOfIndexParameters;1], however in the TAST, indexed property setters // are uncurried and have arity [numberOfIndexParameters+1]. // - // Here we work around this mismatch by crunching all property argument lists to uncirred form. + // Here we work around this mismatch by crunching all property argument lists to uncurried form. // Ideally the problem needs to be solved at its root cause at the callsites to this function let unnamedCurriedCallerArgs, namedCurriedCallerArgs = if isProp then @@ -11173,7 +11173,7 @@ and TcLetBinding cenv isUse env containerInfo declKind tpenv (synBinds, synBinds /// RECAP: /// The LHS of let-bindings are patterns. /// These patterns could fail, e.g. "let Some x = ...". -/// So letbindings could contain a fork at a match construct, with one branch being the match failure. +/// So let bindings could contain a fork at a match construct, with one branch being the match failure. /// If bindings are linearised, then this fork is pushed to the RHS. /// In this case, the let bindings type check to a sequence of bindings. and TcLetBindings cenv env containerInfo declKind tpenv (binds, bindsm, scopem) = @@ -11416,7 +11416,7 @@ and AnalyzeRecursiveStaticMemberOrValDecl let vis = CombineVisibilityAttribs vis1 vis2 mBinding // Check if we're defining a member, in which case generate the internal unique - // name for the member and the information about which type it is agumenting + // name for the member and the information about which type it is augmenting match tcrefContainerInfo, memberFlagsOpt with | (Some(MemberOrValContainerInfo(tcref, optIntfSlotTy, baseValOpt, _safeInitInfo, declaredTyconTypars)), Some memberFlags) -> @@ -11636,7 +11636,7 @@ and AnalyzeAndMakeAndPublishRecursiveValue overridesOK isGeneratedEventVal cenv let isComplete = ComputeIsComplete enclosingDeclaredTypars declaredTypars ty // NOTE: The type scheme here is normally not 'complete'!!!! The type is more or less just a type variable at this point. - // NOTE: toparity, type and typars get fixed-up after inference + // NOTE: top arity, type and typars get fixed-up after inference let prelimTyscheme = TypeScheme(enclosingDeclaredTypars@declaredTypars, ty) let partialValReprInfo = TranslateTopValSynInfo mBinding (TcAttributes cenv envinner) valSynInfo let topValInfo = UseSyntacticArity declKind prelimTyscheme partialValReprInfo @@ -11813,7 +11813,7 @@ and TcIncrementalLetRecGeneralization cenv scopem // - This table is usually much smaller than the number of remaining forward declarations ? e.g. in the pathological case you mentioned below this table is size 1. // - If a forward declaration does not have an entry in this table then its type can't involve any inference variables from the declarations we have already checked. // - So by scanning the domain of this table we can reduce the complexity down to something like O(n * average-number-of-forward-calls). - // - For a fully connected programs or programs where every forward declaration is subject to a forward call, this would be quadratic. However we do not expect callgraphs to be like this in practice + // - For a fully connected programs or programs where every forward declaration is subject to a forward call, this would be quadratic. However we do not expect call graphs to be like this in practice // // Hence we use the recursive-uses table to guide the process of scraping forward references for frozen types // If the is no entry in the recursive use table then a forward binding has never been used and @@ -12180,8 +12180,8 @@ and TcLetrec overridesOK cenv env tpenv (binds, bindsm, scopem) = let results = EliminateInitializationGraphs - (fun _ -> failwith "unreachable 2 - no type definitions in recursivve group") - (fun _ _ -> failwith "unreachable 3 - no type definitions in recursivve group") + (fun _ -> failwith "unreachable 2 - no type definitions in recursive group") + (fun _ _ -> failwith "unreachable 3 - no type definitions in recursive group") id (fun morpher oldBinds -> morpher oldBinds) cenv.g mustHaveArity env.DisplayEnv [MutRecShape.Lets bindsWithoutLaziness] bindsm @@ -12540,7 +12540,7 @@ module IncrClassChecking = TyconRef: TyconRef /// The type parameters allocated for the implicit instance constructor. - /// These may be equated with other (WillBeRigid) type parameters through equirecursive inference, and so + /// These may be equated with other (WillBeRigid) type parameters through equi-recursive inference, and so /// should always be renormalized/canonicalized when used. InstanceCtorDeclaredTypars: Typars @@ -12582,7 +12582,7 @@ module IncrClassChecking = /// Check and elaborate the "left hand side" of the implicit class construction /// syntax. - let TcImplictCtorLhs_Phase2A(cenv, env, tpenv, tcref: TyconRef, vis, attrs, spats, thisIdOpt, baseValOpt: Val option, safeInitInfo, m, copyOfTyconTypars, objTy, thisTy) = + let TcImplicitCtorLhs_Phase2A(cenv, env, tpenv, tcref: TyconRef, vis, attrs, spats, thisIdOpt, baseValOpt: Val option, safeInitInfo, m, copyOfTyconTypars, objTy, thisTy) = let baseValOpt = match GetSuperTypeOfType cenv.g cenv.amap m objTy with @@ -13164,12 +13164,12 @@ module IncrClassChecking = // Note: the recursive calls are made via members on the object // or via access to fields. This means the recursive loop is "broken", // and we can collapse to sequential bindings - let reps = (reps, binds) ||> List.fold (fun rep bind -> rep.ValNowWithRepresentation bind.Var) // inscope before + let reps = (reps, binds) ||> List.fold (fun rep bind -> rep.ValNowWithRepresentation bind.Var) // in scope before let actions, methodBinds = binds |> List.map (TransBind reps) |> List.unzip // since can occur in RHS of own defns actions, reps, methodBinds else let actions, methodBinds = binds |> List.map (TransBind reps) |> List.unzip - let reps = (reps, binds) ||> List.fold (fun rep bind -> rep.ValNowWithRepresentation bind.Var) // inscope after + let reps = (reps, binds) ||> List.fold (fun rep bind -> rep.ValNowWithRepresentation bind.Var) // in scope after actions, reps, methodBinds let methodBinds = List.concat methodBinds if isStatic then @@ -13439,16 +13439,16 @@ module MutRecBindingChecking = // Class members can access protected members of the implemented type // Class members can access private members in the ty let isExtrinsic = (declKind = ExtrinsicExtensionBinding) - let initalEnvForTycon = MakeInnerEnvForTyconRef envForDecls tcref isExtrinsic + let initialEnvForTycon = MakeInnerEnvForTyconRef envForDecls tcref isExtrinsic // Re-add the type constructor to make it take precedence for record label field resolutions // This does not apply to extension members: in those cases the relationship between the record labels // and the type is too extruded let envForTycon = if isExtrinsic then - initalEnvForTycon + initialEnvForTycon else - AddLocalTyconRefs true g cenv.amap tcref.Range [tcref] initalEnvForTycon + AddLocalTyconRefs true g cenv.amap tcref.Range [tcref] initialEnvForTycon // Make fresh version of the class type for type checking the members and lets * let _, copyOfTyconTypars, _, objTy, thisTy = FreshenObjectArgType cenv tcref.Range TyparRigidity.WillBeRigid tcref isExtrinsic declaredTyconTypars @@ -13477,7 +13477,7 @@ module MutRecBindingChecking = error(Error(FSComp.SR.tcMeasureDeclarationsRequireStaticMembers(), m)) // Phase2A: make incrClassCtorLhs - ctorv, thisVal etc, type depends on argty(s) - let incrClassCtorLhs = TcImplictCtorLhs_Phase2A(cenv, envForTycon, tpenv, tcref, vis, attrs, spats, thisIdOpt, baseValOpt, safeInitInfo, m, copyOfTyconTypars, objTy, thisTy) + let incrClassCtorLhs = TcImplicitCtorLhs_Phase2A(cenv, envForTycon, tpenv, tcref, vis, attrs, spats, thisIdOpt, baseValOpt, safeInitInfo, m, copyOfTyconTypars, objTy, thisTy) // Phase2A: Add copyOfTyconTypars from incrClassCtorLhs - or from tcref let envForTycon = AddDeclaredTypars CheckForDuplicateTypars incrClassCtorLhs.InstanceCtorDeclaredTypars envForTycon let innerState = (Some incrClassCtorLhs, envForTycon, tpenv, recBindIdx, uncheckedBindsRev) @@ -14451,7 +14451,7 @@ module TyconConstraintInference = yield tycon.Stamp ] // Initially, don't assume that the equality relation is dependent on any type variables - let initialAsssumedTypars = Set.empty + let initialAssumedTypars = Set.empty // Repeatedly eliminate structural type definitions whose structural component types no longer support // comparison. On the way record type variables which are support the comparison relation. @@ -14557,7 +14557,7 @@ module TyconConstraintInference = else loop newSet !assumedTyparsAcc - let uneliminatedTycons, assumedTyparsActual = loop initialAssumedTycons initialAsssumedTypars + let uneliminatedTycons, assumedTyparsActual = loop initialAssumedTycons initialAssumedTypars // OK, we're done, Record the results for the type variable which provide the support for tyconStamp in uneliminatedTycons do @@ -14598,7 +14598,7 @@ module TyconConstraintInference = if tp.Constraints |> List.exists (function TyparConstraint.SupportsEquality _ -> true | _ -> false) then true - // Within structural types, type parameters can be optimistically assumed to have ewquality + // Within structural types, type parameters can be optimistically assumed to have equality // We record the ones for which we have made this assumption. elif tycon.Typars(tycon.Range) |> List.exists (fun tp2 -> typarRefEq tp tp2) then assumedTyparsAcc := (!assumedTyparsAcc).Add(tp.Stamp) @@ -15415,7 +15415,7 @@ module EstablishTypeDefinitionCores = with e -> errorRecovery e m - // Third phase: check and publish the supr types. Run twice, once before constraints are established + // Third phase: check and publish the super types. Run twice, once before constraints are established // and once after let private TcTyconDefnCore_Phase1D_Phase1F_EstablishSuperTypesAndInterfaceTypes cenv tpenv inSig pass (envMutRec, mutRecDefns: MutRecShape<(_ * (Tycon * (Attribs * _)) option), _, _, _, _> list) = let checkCxs = if (pass = SecondPass) then CheckCxs else NoCheckCxs @@ -15545,7 +15545,7 @@ module EstablishTypeDefinitionCores = let hasMeasureAttr = HasFSharpAttribute g g.attrib_MeasureAttribute attrs // REVIEW: for hasMeasureableAttr we need to be stricter about checking these - // are only used on exactly the right kinds of type definitions and not inconjunction with other attributes. + // are only used on exactly the right kinds of type definitions and not in conjunction with other attributes. let hasMeasureableAttr = HasFSharpAttribute g g.attrib_MeasureableAttribute attrs let hasCLIMutable = HasFSharpAttribute g g.attrib_CLIMutableAttribute attrs @@ -16433,7 +16433,7 @@ module TcDeclarations = | SynMemberDefn.Inherit _ | SynMemberDefn.AbstractSlot _ -> false) - // Convert autoproperties to let bindings in the pre-list + // Convert auto properties to let bindings in the pre-list let rec preAutoProps memb = match memb with | SynMemberDefn.AutoProperty(Attributes attribs, isStatic, id, tyOpt, propKind, _, xmlDoc, _access, synExpr, _mGetSet, mWholeAutoProp) -> @@ -16460,7 +16460,7 @@ module TcDeclarations = | SynMemberDefn.ImplicitInherit _ -> [memb] | _ -> [] - // Convert autoproperties to member bindings in the post-list + // Convert auto properties to member bindings in the post-list let rec postAutoProps memb = match memb with | SynMemberDefn.AutoProperty(Attributes attribs, isStatic, id, tyOpt, propKind, memberFlags, xmlDoc, access, _synExpr, mGetSetOpt, _mWholeAutoProp) -> diff --git a/src/fsharp/ast.fs b/src/fsharp/ast.fs index 59e93205ce1..0a00cd44347 100644 --- a/src/fsharp/ast.fs +++ b/src/fsharp/ast.fs @@ -1368,7 +1368,7 @@ and and [] SynExceptionDefnRepr = - | SynExceptionDefnRepr of SynAttributes * SynUnionCase * longId: LongIdent option * xmlDoc: PreXmlDoc * accessiblity: SynAccess option * range: range + | SynExceptionDefnRepr of SynAttributes * SynUnionCase * longId: LongIdent option * xmlDoc: PreXmlDoc * accessibility: SynAccess option * range: range member this.Range = match this with SynExceptionDefnRepr (range=m) -> m @@ -1416,7 +1416,7 @@ and | Member of memberDefn: SynBinding * range: range /// implicit ctor args as a defn line, 'as' specification - | ImplicitCtor of accessiblity: SynAccess option * attributes: SynAttributes * ctorArgs: SynSimplePats * selfIdentifier: Ident option * range: range + | ImplicitCtor of accessibility: SynAccess option * attributes: SynAttributes * ctorArgs: SynSimplePats * selfIdentifier: Ident option * range: range /// inherit (args...) as base | ImplicitInherit of inheritType: SynType * inheritArgs: SynExpr * inheritAlias: Ident option * range: range @@ -1448,7 +1448,7 @@ and propKind: MemberKind * memberFlags:(MemberKind -> MemberFlags) * xmlDoc: PreXmlDoc * - accessiblity: SynAccess option * + accessibility: SynAccess option * synExpr: SynExpr * getSetRange: range option * range: range @@ -1760,15 +1760,15 @@ let (|SynPatErrorSkip|) (p: SynPat) = let rec SimplePatOfPat (synArgNameGenerator: SynArgNameGenerator) p = match p with | SynPat.Typed(p', ty, m) -> - let p2, laterf = SimplePatOfPat synArgNameGenerator p' + let p2, laterF = SimplePatOfPat synArgNameGenerator p' SynSimplePat.Typed(p2, ty, m), - laterf + laterF | SynPat.Attrib(p', attribs, m) -> - let p2, laterf = SimplePatOfPat synArgNameGenerator p' + let p2, laterF = SimplePatOfPat synArgNameGenerator p' SynSimplePat.Attrib(p2, attribs, m), - laterf - | SynPat.Named (SynPat.Wild _, v, thisv, _, m) -> - SynSimplePat.Id (v, None, false, thisv, false, m), + laterF + | SynPat.Named (SynPat.Wild _, v, thisV, _, m) -> + SynSimplePat.Id (v, None, false, thisV, false, m), None | SynPat.OptionalVal (v, m) -> SynSimplePat.Id (v, None, false, false, true, m), @@ -1803,13 +1803,13 @@ let rec SimplePatsOfPat synArgNameGenerator p = match p with | SynPat.FromParseError (p, _) -> SimplePatsOfPat synArgNameGenerator p | SynPat.Typed(p', ty, m) -> - let p2, laterf = SimplePatsOfPat synArgNameGenerator p' + let p2, laterF = SimplePatsOfPat synArgNameGenerator p' SynSimplePats.Typed(p2, ty, m), - laterf + laterF // | SynPat.Paren (p, m) -> SimplePatsOfPat synArgNameGenerator p | SynPat.Tuple (false, ps, m) | SynPat.Paren(SynPat.Tuple (false, ps, m), _) -> - let ps2, laterf = + let ps2, laterF = List.foldBack (fun (p', rhsf) (ps', rhsf') -> p':: ps', @@ -1817,23 +1817,23 @@ let rec SimplePatsOfPat synArgNameGenerator p = (List.map (SimplePatOfPat synArgNameGenerator) ps) ([], None) SynSimplePats.SimplePats (ps2, m), - laterf + laterF | SynPat.Paren(SynPat.Const (SynConst.Unit, m), _) | SynPat.Const (SynConst.Unit, m) -> SynSimplePats.SimplePats ([], m), None | _ -> let m = p.Range - let sp, laterf = SimplePatOfPat synArgNameGenerator p - SynSimplePats.SimplePats ([sp], m), laterf + let sp, laterF = SimplePatOfPat synArgNameGenerator p + SynSimplePats.SimplePats ([sp], m), laterF let PushPatternToExpr synArgNameGenerator isMember pat (rhs: SynExpr) = - let nowpats, laterf = SimplePatsOfPat synArgNameGenerator pat - nowpats, SynExpr.Lambda (isMember, false, nowpats, appFunOpt laterf rhs, rhs.Range) + let nowPats, laterF = SimplePatsOfPat synArgNameGenerator pat + nowPats, SynExpr.Lambda (isMember, false, nowPats, appFunOpt laterF rhs, rhs.Range) let private isSimplePattern pat = - let _nowpats, laterf = SimplePatsOfPat (SynArgNameGenerator()) pat - Option.isNone laterf + let _nowPats, laterF = SimplePatsOfPat (SynArgNameGenerator()) pat + Option.isNone laterF /// "fun (UnionCase x) (UnionCase y) -> body" /// ==> @@ -1950,15 +1950,15 @@ let mkSynDotBrackGet m mDot a b = SynExpr.DotIndexedGet (a, [SynIndexerArg.On let mkSynQMarkSet m a b c = mkSynTrifix m qmarkSet a b c let mkSynDotBrackSliceGet m mDot arr sliceArg = SynExpr.DotIndexedGet (arr, [sliceArg], mDot, m) -let mkSynDotBrackSeqSliceGet m mDot arr (argslist: list) = - let notsliced=[ for arg in argslist do +let mkSynDotBrackSeqSliceGet m mDot arr (argsList: list) = + let notSliced=[ for arg in argsList do match arg with | SynIndexerArg.One x -> yield x | _ -> () ] - if notsliced.Length = argslist.Length then - SynExpr.DotIndexedGet (arr, [SynIndexerArg.One (SynExpr.Tuple (false, notsliced, [], unionRanges (List.head notsliced).Range (List.last notsliced).Range))], mDot, m) + if notSliced.Length = argsList.Length then + SynExpr.DotIndexedGet (arr, [SynIndexerArg.One (SynExpr.Tuple (false, notSliced, [], unionRanges (List.head notSliced).Range (List.last notSliced).Range))], mDot, m) else - SynExpr.DotIndexedGet (arr, argslist, mDot, m) + SynExpr.DotIndexedGet (arr, argsList, mDot, m) let mkSynDotParenGet lhsm dotm a b = match b with @@ -2206,7 +2206,7 @@ let mkSynBindingRhs staticOptimizations rhsExpr mRhs retInfo = let rhsExpr = List.foldBack (fun (c, e1) e2 -> SynExpr.LibraryOnlyStaticOptimization (c, e1, e2, mRhs)) staticOptimizations rhsExpr let rhsExpr, retTyOpt = match retInfo with - | Some (SynReturnInfo((ty, SynArgInfo(rattribs, _, _)), tym)) -> SynExpr.Typed (rhsExpr, ty, rhsExpr.Range), Some(SynBindingReturnInfo(ty, tym, rattribs) ) + | Some (SynReturnInfo((ty, SynArgInfo(rAttribs, _, _)), tym)) -> SynExpr.Typed (rhsExpr, ty, rhsExpr.Range), Some(SynBindingReturnInfo(ty, tym, rAttribs) ) | None -> rhsExpr, None rhsExpr, retTyOpt diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index bfecea2a169..ff5263718f2 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -405,7 +405,7 @@ type internal FsiValuePrinter(fsi: FsiEvaluationSessionHostConfig, g: TcGlobals, // Note: The value may be (null:Object). // Note: A System.Type allows the value printer guide printing of nulls, e.g. as None or []. //------- - // IlxGen knows what the v:Val was converted to w.r.t. AbsIL datastructures. + // IlxGen knows what the v:Val was converted to w.r.t. AbsIL data structures. // Ilreflect knows what the AbsIL was generated to. // Combining these allows for obtaining the (obj,objTy) by reflection where possible. // This assumes the v:Val was given appropriate storage, e.g. StaticField. @@ -1254,7 +1254,7 @@ type internal FsiDynamicCompiler with e -> tcConfigB.RemoveReferencedAssemblyByPath(m,path) reraise() - let optEnv = List.fold (AddExternalCcuToOpimizationEnv tcGlobals) istate.optEnv ccuinfos + let optEnv = List.fold (AddExternalCcuToOptimizationEnv tcGlobals) istate.optEnv ccuinfos istate.ilxGenerator.AddExternalCcus (ccuinfos |> List.map (fun ccuinfo -> ccuinfo.FSharpViewOfMetadata)) resolutions, { istate with tcState = tcState.NextStateAfterIncrementalFragment(tcEnv); optEnv = optEnv } @@ -1401,7 +1401,7 @@ type internal FsiInterruptController(fsiOptions: FsiCommandLineOptions, fsiConso member controller.InstallKillThread(threadToKill:Thread, pauseMilliseconds:int) = - // Fsi Interupt handler + // Fsi Interrupt handler let raiseCtrlC() = use _scope = SetCurrentUICultureForThread fsiOptions.FsiLCID fprintf fsiConsoleOutput.Error "%s" (FSIstrings.SR.fsiInterrupt()) @@ -1623,11 +1623,11 @@ type internal FsiStdinLexerProvider let isFeatureSupported featureId = tcConfigB.langVersion.SupportsFeature featureId - let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) readf = + let LexbufFromLineReader (fsiStdinSyphon: FsiStdinSyphon) readF = UnicodeLexing.FunctionAsLexbuf (isFeatureSupported, (fun (buf: char[], start, len) -> //fprintf fsiConsoleOutput.Out "Calling ReadLine\n" - let inputOption = try Some(readf()) with :? EndOfStreamException -> None + let inputOption = try Some(readF()) with :? EndOfStreamException -> None inputOption |> Option.iter (fun t -> fsiStdinSyphon.Add (t + "\n")) match inputOption with | Some(null) | None -> @@ -2699,7 +2699,7 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i DriveFsiEventLoop (fsi, fsiConsoleOutput ) else // not interact - if !progress then fprintfn fsiConsoleOutput.Out "Run: not interact, loading intitial files..." + if !progress then fprintfn fsiConsoleOutput.Out "Run: not interact, loading initial files..." fsiInteractionProcessor.LoadInitialFiles(ctokRun, errorLogger) if !progress then fprintfn fsiConsoleOutput.Out "Run: done..." @@ -2749,7 +2749,7 @@ module Settings = abstract Invoke : (unit -> 'T) -> 'T abstract ScheduleRestart : unit -> unit - // fsi.fs in FSHarp.Compiler.Sevice.dll avoids a hard dependency on FSharp.Compiler.Interactive.Settings.dll + // fsi.fs in FSHarp.Compiler.Service.dll avoids a hard dependency on FSharp.Compiler.Interactive.Settings.dll // by providing an optional reimplementation of the functionality // An implementation of IEventLoop suitable for the command-line console diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index 8cc0b23fed0..bed1b74e61a 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -125,10 +125,10 @@ type FsiEvaluationSession = /// Create an FsiEvaluationSession, reading from the given text input, writing to the given text output and error writers /// /// The dynamic configuration of the evaluation session - /// The commmand line arguments for the evaluation session + /// The command line arguments for the evaluation session /// Read input from the given reader /// Write output to the given writer - /// Optionally make the dynamic assmbly for the session collectible + /// Optionally make the dynamic assembly for the session collectible static member Create : fsiConfig: FsiEvaluationSessionHostConfig * argv:string[] * inReader:TextReader * outWriter:TextWriter * errorWriter: TextWriter * ?collectible: bool * ?legacyReferenceResolver: ReferenceResolver.Resolver -> FsiEvaluationSession /// A host calls this to request an interrupt on the evaluation thread. @@ -177,7 +177,7 @@ type FsiEvaluationSession = /// Execute the code as if it had been entered as one or more interactions, with an /// implicit termination at the end of the input. Stop on first error, discarding the rest /// of the input. Errors are sent to the output writer. Parsing is performed on the current thread, and execution is performed - /// sycnhronously on the 'main' thread. + /// synchronously on the 'main' thread. /// /// Due to a current limitation, it is not fully thread-safe to run this operation concurrently with evaluation triggered /// by input from 'stdin'. @@ -187,7 +187,7 @@ type FsiEvaluationSession = /// implicit termination at the end of the input. Stop on first error, discarding the rest /// of the input. Errors and warnings are collected apart from any exception arising from execution /// which is returned via a Choice. Parsing is performed on the current thread, and execution is performed - /// sycnhronously on the 'main' thread. + /// synchronously on the 'main' thread. /// /// Due to a current limitation, it is not fully thread-safe to run this operation concurrently with evaluation triggered /// by input from 'stdin'. @@ -222,7 +222,7 @@ type FsiEvaluationSession = /// Get a handle to the resolved view of the current signature of the incrementally generated assembly. member CurrentPartialAssemblySignature : FSharpAssemblySignature - /// Get a handle to the dynamicly generated assembly + /// Get a handle to the dynamically generated assembly member DynamicAssembly : System.Reflection.Assembly /// A host calls this to determine if the --gui parameter is active @@ -320,7 +320,7 @@ module Settings = /// A default implementation of the 'fsi' object, used by GetDefaultConfiguration(). Note this /// is a different object to FSharp.Compiler.Interactive.Settings.fsi in FSharp.Compiler.Interactive.Settings.dll, - /// which can be used as an alternative implementation of the interactiev settings if passed as a parameter + /// which can be used as an alternative implementation of the interactive settings if passed as a parameter /// to GetDefaultConfiguration(fsiObj). val fsi : InteractiveSettings diff --git a/src/fsharp/infos.fs b/src/fsharp/infos.fs index 4ca16f77cdd..0231d5f2ab0 100755 --- a/src/fsharp/infos.fs +++ b/src/fsharp/infos.fs @@ -1077,7 +1077,7 @@ type MethInfo = /// For an extension method this includes all type parameters, even if it is extending a generic type. member x.GenericArity = x.FormalMethodTypars.Length - member x.IsProtectedAccessiblity = + member x.IsProtectedAccessibility = match x with | ILMeth(_, ilmeth, _) -> ilmeth.IsProtectedAccessibility | FSMeth _ -> false @@ -2476,7 +2476,7 @@ type EventInfo = /// Test whether two event infos have the same underlying definition. /// Must be compatible with ItemsAreEffectivelyEqual relation. - static member EventInfosUseIdenticalDefintions x1 x2 = + static member EventInfosUseIdenticalDefinitions x1 x2 = match x1, x2 with | FSEvent(g, pi1, vrefa1, vrefb1), FSEvent(_, pi2, vrefa2, vrefb2) -> PropInfo.PropInfosUseIdenticalDefinitions pi1 pi2 && valRefEq g vrefa1 vrefa2 && valRefEq g vrefb1 vrefb2 diff --git a/src/fsharp/layout.fs b/src/fsharp/layout.fs index d63a8f8f023..f6e35cfb612 100644 --- a/src/fsharp/layout.fs +++ b/src/fsharp/layout.fs @@ -389,7 +389,7 @@ type LayoutRenderer<'a, 'b> = let renderL (rr: LayoutRenderer<_, _>) layout = let rec addL z pos i layout k = match layout with - | ObjLeaf _ -> failwith "ObjLeaf should never apper here" + | ObjLeaf _ -> failwith "ObjLeaf should never appear here" (* pos is tab level *) | Leaf (_, text, _) -> k(rr.AddText z text, i + text.Text.Length) diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index 6c4599f8a1c..f626cdd022f 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -98,31 +98,31 @@ module Check = /// Throw System.InvalidOperationException() if argument is None. /// If there is a value (e.g. Some(value)) then value is returned. - let NotNone argname (arg:'T option) : 'T = + let NotNone argName (arg:'T option) : 'T = match arg with - | None -> raise (new System.InvalidOperationException(argname)) + | None -> raise (new System.InvalidOperationException(argName)) | Some x -> x /// Throw System.ArgumentNullException() if argument is null. - let ArgumentNotNull arg argname = + let ArgumentNotNull arg argName = match box(arg) with - | null -> raise (new System.ArgumentNullException(argname)) + | null -> raise (new System.ArgumentNullException(argName)) | _ -> () /// Throw System.ArgumentNullException() if array argument is null. /// Throw System.ArgumentOutOfRangeException() is array argument is empty. - let ArrayArgumentNotNullOrEmpty (arr:'T[]) argname = - ArgumentNotNull arr argname + let ArrayArgumentNotNullOrEmpty (arr:'T[]) argName = + ArgumentNotNull arr argName if (0 = arr.Length) then - raise (new System.ArgumentOutOfRangeException(argname)) + raise (new System.ArgumentOutOfRangeException(argName)) /// Throw System.ArgumentNullException() if string argument is null. /// Throw System.ArgumentOutOfRangeException() is string argument is empty. - let StringArgumentNotNullOrEmpty (s:string) argname = - ArgumentNotNull s argname + let StringArgumentNotNullOrEmpty (s:string) argName = + ArgumentNotNull s argName if s.Length = 0 then - raise (new System.ArgumentNullException(argname)) + raise (new System.ArgumentNullException(argName)) //------------------------------------------------------------------------- // Library @@ -378,10 +378,10 @@ let nullableSlotFull x = x type cache<'T> = { mutable cacheVal: 'T NonNullSlot } let newCache() = { cacheVal = nullableSlotEmpty() } -let inline cached cache resf = +let inline cached cache resF = match box cache.cacheVal with | null -> - let res = resf() + let res = resF() cache.cacheVal <- nullableSlotFull res res | _ -> @@ -419,11 +419,11 @@ module internal AsyncUtil = | AsyncCanceled of OperationCanceledException static member Commit(res:AsyncResult<'T>) = - Async.FromContinuations (fun (cont, econt, ccont) -> + Async.FromContinuations (fun (cont, eCont, cCont) -> match res with | AsyncOk v -> cont v - | AsyncException exn -> econt exn - | AsyncCanceled exn -> ccont exn) + | AsyncException exn -> eCont exn + | AsyncCanceled exn -> cCont exn) /// When using .NET 4.0 you can replace this type by [] @@ -446,7 +446,7 @@ module internal AsyncUtil = else result <- Some res // Invoke continuations in FIFO order - // Continuations that Async.FromContinuations provide do QUWI/SynchContext.Post, + // Continuations that Async.FromContinuations provide do QUWI/SyncContext.Post, // so the order is not overly relevant but still. List.rev savedConts) let postOrQueue (sc:SynchronizationContext, cont) = diff --git a/src/fsharp/range.fs b/src/fsharp/range.fs index 0b6d7d39639..e9b44a63977 100755 --- a/src/fsharp/range.fs +++ b/src/fsharp/range.fs @@ -208,8 +208,8 @@ let mkPos l c = pos (l, c) #endif type range(code1:int64, code2: int64) = static member Zero = range(0L, 0L) - new (fidx, bl, bc, el, ec) = - let code1 = ((int64 fidx) &&& fileIndexMask) + new (fIdx, bl, bc, el, ec) = + let code1 = ((int64 fIdx) &&& fileIndexMask) ||| ((int64 bc <<< startColumnShift) &&& startColumnMask) ||| ((int64 ec <<< endColumnShift) &&& endColumnMask) let code2 = @@ -217,7 +217,7 @@ type range(code1:int64, code2: int64) = ||| ((int64 (el-bl) <<< heightShift) &&& heightMask) range(code1, code2) - new (fidx, b:pos, e:pos) = range(fidx, b.Line, b.Column, e.Line, e.Column) + new (fIdx, b:pos, e:pos) = range(fIdx, b.Line, b.Column, e.Line, e.Column) member r.StartLine = int32((code2 &&& startLineMask) >>> startLineShift) diff --git a/src/fsharp/service/FSharpCheckerResults.fs b/src/fsharp/service/FSharpCheckerResults.fs index d17b56c0854..c3990eb1321 100644 --- a/src/fsharp/service/FSharpCheckerResults.fs +++ b/src/fsharp/service/FSharpCheckerResults.fs @@ -1353,7 +1353,7 @@ type internal TypeCheckInfo | CNR(_, (Item.CustomBuilder _ | Item.CustomOperation _), ItemOccurence.Use, _, _, _, m) -> Some (m, SemanticClassificationType.ComputationExpression) // types get colored as types when they occur in syntactic types or custom attributes - // typevariables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords + // type variables get colored as types when they occur in syntactic types custom builders, custom operations get colored as keywords | CNR(_, Item.Types (_, [OptionalArgumentAttribute]), LegitTypeOccurence, _, _, _, _) -> None | CNR(_, Item.CtorGroup(_, [MethInfo.FSMeth(_, OptionalArgumentAttribute, _, _)]), LegitTypeOccurence, _, _, _, _) -> None | CNR(_, Item.Types(_, types), LegitTypeOccurence, _, _, _, m) when types |> List.exists (isInterfaceTy g) -> @@ -1446,7 +1446,7 @@ type FSharpParsingOptions = CompilingFsLib = tcConfig.compilingFslib IsExe = tcConfig.target.IsExe } - static member FromTcConfigBuidler(tcConfigB: TcConfigBuilder, sourceFiles, isInteractive: bool) = + static member FromTcConfigBuilder(tcConfigB: TcConfigBuilder, sourceFiles, isInteractive: bool) = { SourceFiles = sourceFiles ConditionalCompilationDefines = tcConfigB.conditionalCompilationDefines @@ -2104,7 +2104,7 @@ type FSharpCheckProjectResults let (tcGlobals, tcImports, thisCcu, ccuSig, _tcSymbolUses, topAttribs, _tcAssemblyData, _ilAssemRef, _ad, _tcAssemblyExpr, _dependencyFiles) = getDetails() FSharpAssemblySignature(tcGlobals, thisCcu, ccuSig, tcImports, topAttribs, ccuSig) - member __.TypedImplementionFiles = + member __.TypedImplementationFiles = if not keepAssemblyContents then invalidOp "The 'keepAssemblyContents' flag must be set to true on the FSharpChecker in order to access the checked contents of assemblies" let (tcGlobals, tcImports, thisCcu, _ccuSig, _tcSymbolUses, _topAttribs, _tcAssemblyData, _ilAssemRef, _ad, tcAssemblyExpr, _dependencyFiles) = getDetails() let mimpls = diff --git a/src/fsharp/service/FSharpCheckerResults.fsi b/src/fsharp/service/FSharpCheckerResults.fsi index 4f7062d9ce2..13496225bfb 100644 --- a/src/fsharp/service/FSharpCheckerResults.fsi +++ b/src/fsharp/service/FSharpCheckerResults.fsi @@ -89,7 +89,7 @@ type public FSharpParsingOptions = static member internal FromTcConfig: tcConfig: TcConfig * sourceFiles: string[] * isInteractive: bool -> FSharpParsingOptions - static member internal FromTcConfigBuidler: tcConfigB: TcConfigBuilder * sourceFiles: string[] * isInteractive: bool -> FSharpParsingOptions + static member internal FromTcConfigBuilder: tcConfigB: TcConfigBuilder * sourceFiles: string[] * isInteractive: bool -> FSharpParsingOptions /// A handle to the results of CheckFileInProject. [] diff --git a/src/fsharp/service/IncrementalBuild.fs b/src/fsharp/service/IncrementalBuild.fs index 96e81e32147..ce24bbcb163 100755 --- a/src/fsharp/service/IncrementalBuild.fs +++ b/src/fsharp/service/IncrementalBuild.fs @@ -253,9 +253,9 @@ module internal IncrementalBuild = static member OfSize size = ResultVector(size, DateTime.MinValue, Map.empty) member rv.Size = size member rv.Get slot = get slot - member rv.Resize newsize = - if size<>newsize then - ResultVector(newsize, zeroElementTimestamp, map |> Map.filter(fun s _ -> s < newsize)) + member rv.Resize newSize = + if size<>newSize then + ResultVector(newSize, zeroElementTimestamp, map |> Map.filter(fun s _ -> s < newSize)) else rv member rv.Set(slot, value) = @@ -266,7 +266,7 @@ module internal IncrementalBuild = ResultVector(size, zeroElementTimestamp, Map.add slot value map) member rv.MaxTimestamp() = - let maximize (lasttimestamp: DateTime) (_, result: Result) = max lasttimestamp result.Timestamp + let maximize (lastTimestamp: DateTime) (_, result: Result) = max lastTimestamp result.Timestamp List.fold maximize zeroElementTimestamp (asList.Force()) member rv.Signature() = @@ -416,16 +416,16 @@ module internal IncrementalBuild = /// Get the maximum build stamp for an output. let MaxTimestamp(bt: PartialBuild, id) = match bt.Results.TryFind id with - | Some resultset -> - match resultset with + | Some resultSet -> + match resultSet with | ScalarResult rs -> rs.Timestamp | VectorResult rv -> rv.MaxTimestamp() | None -> DateTime.MaxValue let Signature(bt: PartialBuild, id) = match bt.Results.TryFind id with - | Some resultset -> - match resultset with + | Some resultSet -> + match resultSet with | ScalarResult rs -> rs.InputSignature | VectorResult rv -> rv.Signature() | None -> UnevaluatedInput @@ -515,9 +515,9 @@ module internal IncrementalBuild = seen.[id] <- true false - let shouldEvaluate(bt, currentsig: InputSignature, id) = - if currentsig.IsEvaluated then - currentsig <> Signature(bt, id) + let shouldEvaluate(bt, currentSig: InputSignature, id) = + if currentSig.IsEvaluated then + currentSig <> Signature(bt, id) else false /// Make sure the result vector saved matches the size of expr @@ -555,20 +555,20 @@ module internal IncrementalBuild = let inputResult = GetVectorExprResult (bt, inputExpr, slot) match accumulatorResult, inputResult with - | Available (accumulator, accumulatortimesamp, _accumulatorInputSig), Available (input, inputtimestamp, _inputSig) -> - let inputtimestamp = max inputtimestamp accumulatortimesamp - let prevoutput = GetVectorExprResult (bt, ve, slot) - let outputtimestamp = prevoutput.Timestamp + | Available (accumulator, accumulatorTimestamp, _accumulatorInputSig), Available (input, inputTimestamp, _inputSig) -> + let inputTimestamp = max inputTimestamp accumulatorTimestamp + let prevOutput = GetVectorExprResult (bt, ve, slot) + let outputTimestamp = prevOutput.Timestamp let scanOpOpt = - if inputtimestamp <> outputtimestamp then + if inputTimestamp <> outputTimestamp then Some (fun ctok -> func ctok accumulator input) - elif prevoutput.ResultIsInProgress then - Some prevoutput.GetInProgressContinuation + elif prevOutput.ResultIsInProgress then + Some prevOutput.GetInProgressContinuation else // up-to-date and complete, no work required None match scanOpOpt with - | Some scanOp -> Some (actionFunc (IndexedAction(id, taskname, slot, cardinality, inputtimestamp, scanOp)) acc) + | Some scanOp -> Some (actionFunc (IndexedAction(id, taskname, slot, cardinality, inputTimestamp, scanOp)) acc) | None -> None | _ -> None @@ -584,19 +584,19 @@ module internal IncrementalBuild = | Some cardinality -> if cardinality=0 then // For vector length zero, just propagate the prior timestamp. - let inputtimestamp = MaxTimestamp(bt, inputExpr.Id) - let outputtimestamp = MaxTimestamp(bt, id) - if inputtimestamp <> outputtimestamp then - actionFunc (VectorAction(id, taskname, inputtimestamp, EmptyTimeStampedInput inputtimestamp, fun _ -> cancellable.Return [||])) acc + let inputTimestamp = MaxTimestamp(bt, inputExpr.Id) + let outputTimestamp = MaxTimestamp(bt, id) + if inputTimestamp <> outputTimestamp then + actionFunc (VectorAction(id, taskname, inputTimestamp, EmptyTimeStampedInput inputTimestamp, fun _ -> cancellable.Return [||])) acc else acc else let MapResults acc slot = - let inputtimestamp = GetVectorExprResult(bt, inputExpr, slot).Timestamp - let outputtimestamp = GetVectorExprResult(bt, ve, slot).Timestamp - if inputtimestamp <> outputtimestamp then + let inputTimestamp = GetVectorExprResult(bt, inputExpr, slot).Timestamp + let outputTimestamp = GetVectorExprResult(bt, ve, slot).Timestamp + if inputTimestamp <> outputTimestamp then let OneToOneOp ctok = Eventually.Done (func ctok (GetVectorExprResult(bt, inputExpr, slot).GetAvailable())) - actionFunc (IndexedAction(id, taskname, slot, cardinality, inputtimestamp, OneToOneOp)) acc + actionFunc (IndexedAction(id, taskname, slot, cardinality, inputTimestamp, OneToOneOp)) acc else acc match optSlot with | None -> @@ -615,20 +615,20 @@ module internal IncrementalBuild = | Some cardinality -> if cardinality=0 then // For vector length zero, just propagate the prior timestamp. - let inputtimestamp = MaxTimestamp(bt, inputExpr.Id) - let outputtimestamp = MaxTimestamp(bt, id) - if inputtimestamp <> outputtimestamp then - actionFunc (VectorAction(id, taskname, inputtimestamp, EmptyTimeStampedInput inputtimestamp, fun _ -> cancellable.Return [||])) acc + let inputTimestamp = MaxTimestamp(bt, inputExpr.Id) + let outputTimestamp = MaxTimestamp(bt, id) + if inputTimestamp <> outputTimestamp then + actionFunc (VectorAction(id, taskname, inputTimestamp, EmptyTimeStampedInput inputTimestamp, fun _ -> cancellable.Return [||])) acc else acc else let checkStamp acc slot = - let inputresult = GetVectorExprResult (bt, inputExpr, slot) - match inputresult with + let inputResult = GetVectorExprResult (bt, inputExpr, slot) + match inputResult with | Available (ires, _, _) -> - let oldtimestamp = GetVectorExprResult(bt, ve, slot).Timestamp - let newtimestamp = func cache ctok ires - if newtimestamp <> oldtimestamp then - actionFunc (IndexedAction(id, taskname, slot, cardinality, newtimestamp, fun _ -> Eventually.Done ires)) acc + let oldTimestamp = GetVectorExprResult(bt, ve, slot).Timestamp + let newTimestamp = func cache ctok ires + if newTimestamp <> oldTimestamp then + actionFunc (IndexedAction(id, taskname, slot, cardinality, newTimestamp, fun _ -> Eventually.Done ires)) acc else acc | _ -> acc match optSlot with @@ -642,11 +642,11 @@ module internal IncrementalBuild = | VectorMultiplex(id, taskname, inputExpr, func) -> let acc = match GetScalarExprResult (bt, inputExpr) with - | Available (inp, inputtimestamp, inputsig) -> - let outputtimestamp = MaxTimestamp(bt, id) - if inputtimestamp <> outputtimestamp then + | Available (inp, inputTimestamp, inputsig) -> + let outputTimestamp = MaxTimestamp(bt, id) + if inputTimestamp <> outputTimestamp then let MultiplexOp ctok = func ctok inp |> cancellable.Return - actionFunc (VectorAction(id, taskname, inputtimestamp, inputsig, MultiplexOp)) acc + actionFunc (VectorAction(id, taskname, inputTimestamp, inputsig, MultiplexOp)) acc else acc | _ -> acc visitScalar inputExpr acc @@ -659,16 +659,16 @@ module internal IncrementalBuild = | ScalarDemultiplex (id, taskname, inputExpr, func) -> let acc = match GetVectorExprResultVector (bt, inputExpr) with - | Some inputresult -> - let currentsig = inputresult.Signature() - if shouldEvaluate(bt, currentsig, id) then - let inputtimestamp = MaxTimestamp(bt, inputExpr.Id) + | Some inputResult -> + let currentSig = inputResult.Signature() + if shouldEvaluate(bt, currentSig, id) then + let inputTimestamp = MaxTimestamp(bt, inputExpr.Id) let DemultiplexOp ctok = cancellable { let input = AvailableAllResultsOfExpr bt inputExpr |> List.toArray return! func ctok input } - actionFunc (ScalarAction(id, taskname, inputtimestamp, currentsig, DemultiplexOp)) acc + actionFunc (ScalarAction(id, taskname, inputTimestamp, currentSig, DemultiplexOp)) acc else acc | None -> acc @@ -677,11 +677,11 @@ module internal IncrementalBuild = | ScalarMap (id, taskname, inputExpr, func) -> let acc = match GetScalarExprResult (bt, inputExpr) with - | Available (inp, inputtimestamp, inputsig) -> - let outputtimestamp = MaxTimestamp(bt, id) - if inputtimestamp <> outputtimestamp then + | Available (inp, inputTimestamp, inputsig) -> + let outputTimestamp = MaxTimestamp(bt, id) + if inputTimestamp <> outputTimestamp then let MapOp ctok = func ctok inp |> cancellable.Return - actionFunc (ScalarAction(id, taskname, inputtimestamp, inputsig, MapOp)) acc + actionFunc (ScalarAction(id, taskname, inputTimestamp, inputsig, MapOp)) acc else acc | _ -> acc @@ -782,10 +782,10 @@ module internal IncrementalBuild = if gen>5000 then failwith "Infinite loop in incremental builder?" #endif - let worklist = CollectActions cache target bt + let workList = CollectActions cache target bt let! newBt = - (bt, worklist) ||> Cancellable.fold (fun bt action -> + (bt, workList) ||> Cancellable.fold (fun bt action -> if injectCancellationFault then Cancellable.canceled() else @@ -800,9 +800,9 @@ module internal IncrementalBuild = cancellable { // REVIEW: we're building up the whole list of actions on the fringe of the work tree, // executing one thing and then throwing the list away. What about saving the list inside the Build instance? - let worklist = CollectActions cache target bt + let workList = CollectActions cache target bt - match worklist with + match workList with | action :: _ -> let! res = ExecuteApply ctok save action bt return Some res @@ -822,8 +822,8 @@ module internal IncrementalBuild = /// Check if an output is up-to-date and ready let IsReady cache target bt = - let worklist = CollectActions cache target bt - worklist.IsEmpty + let workList = CollectActions cache target bt + workList.IsEmpty /// Check if an output is up-to-date and ready let MaxTimeStampInDependencies cache ctok target bt = @@ -972,7 +972,7 @@ module internal IncrementalBuild = -// Record the most recent IncrementalBuilder events, so we can more easily unittest/debug the +// Record the most recent IncrementalBuilder events, so we can more easily unit test/debug the // 'incremental' behavior of the product. module IncrementalBuilderEventTesting = @@ -1054,7 +1054,7 @@ type TypeCheckAccumulator = /// Global service state type FrameworkImportsCacheKey = (*resolvedpath*)string list * string * (*TargetFrameworkDirectories*)string list * (*fsharpBinaries*)string * (*langVersion*)decimal -/// Represents a cache of 'framework' references that can be shared betweeen multiple incremental builds +/// Represents a cache of 'framework' references that can be shared between multiple incremental builds type FrameworkImportsCache(keepStrongly) = // Mutable collection protected via CompilationThreadToken @@ -1087,7 +1087,7 @@ type FrameworkImportsCache(keepStrongly) = tcConfig.primaryAssembly.Name, tcConfig.GetTargetFrameworkDirectories(), tcConfig.fsharpBinariesDir, - tcConfig.langVersion.SpecifiedVerson) + tcConfig.langVersion.SpecifiedVersion) match frameworkTcImportsCache.TryGet (ctok, key) with | Some res -> return res @@ -1141,7 +1141,7 @@ type PartialCheckResults = LatestImplementationFile: TypedImplFile option - LastestCcuSigForFile: ModuleOrNamespaceType option } + LatestCcuSigForFile: ModuleOrNamespaceType option } member x.TcErrors = Array.concat (List.rev x.TcErrorsRev) member x.TcSymbolUses = List.rev x.TcSymbolUsesRev @@ -1161,7 +1161,7 @@ type PartialCheckResults = ModuleNamesDict = tcAcc.tcModuleNamesDict TimeStamp = timestamp LatestImplementationFile = tcAcc.latestImplFile - LastestCcuSigForFile = tcAcc.latestCcuSigForFile } + LatestCcuSigForFile = tcAcc.latestCcuSigForFile } [] @@ -1722,9 +1722,9 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput /// Create a type-check configuration let tcConfigB, sourceFilesNew = - let getSwitchValue switchstring = - match commandLineArgs |> Seq.tryFindIndex(fun s -> s.StartsWithOrdinal switchstring) with - | Some idx -> Some(commandLineArgs.[idx].Substring(switchstring.Length)) + let getSwitchValue switchString = + match commandLineArgs |> Seq.tryFindIndex(fun s -> s.StartsWithOrdinal switchString) with + | Some idx -> Some(commandLineArgs.[idx].Substring(switchString.Length)) | _ -> None // see also fsc.fs: runFromCommandLineToImportingAssemblies(), as there are many similarities to where the PS creates a tcConfigB @@ -1810,7 +1810,7 @@ type IncrementalBuilder(tcGlobals, frameworkTcImports, nonFrameworkAssemblyInput [ for r in nonFrameworkResolutions do let fileName = r.resolvedPath - yield (Choice1Of2 fileName, (fun (cache: TimeStampCache) _ctokk -> cache.GetFileTimeStamp fileName)) + yield (Choice1Of2 fileName, (fun (cache: TimeStampCache) _ctok -> cache.GetFileTimeStamp fileName)) for pr in projectReferences do yield Choice2Of2 pr, (fun (cache: TimeStampCache) ctok -> cache.GetProjectReferenceTimeStamp (pr, ctok)) ] diff --git a/src/fsharp/service/IncrementalBuild.fsi b/src/fsharp/service/IncrementalBuild.fsi index 96d00636887..fb60dbff690 100755 --- a/src/fsharp/service/IncrementalBuild.fsi +++ b/src/fsharp/service/IncrementalBuild.fsi @@ -60,7 +60,7 @@ type internal PartialCheckResults = TcDependencyFiles: string list - /// Represents the collected attributes to apply to the module of assuembly generates + /// Represents the collected attributes to apply to the module of assembly generates TopAttribs: TypeChecker.TopAttribs option TimeStamp: DateTime @@ -70,7 +70,7 @@ type internal PartialCheckResults = LatestImplementationFile: TypedImplFile option /// Represents latest inferred signature contents. - LastestCcuSigForFile: ModuleOrNamespaceType option} + LatestCcuSigForFile: ModuleOrNamespaceType option} member TcErrors: (PhasedDiagnostic * FSharpErrorSeverity)[] @@ -163,7 +163,7 @@ type internal IncrementalBuilder = static member TryCreateBackgroundBuilderForProjectOptions : CompilationThreadToken * ReferenceResolver.Resolver * defaultFSharpBinariesDir: string * FrameworkImportsCache * scriptClosureOptions:LoadClosure option * sourceFiles:string list * commandLineArgs:string list * projectReferences: IProjectReference list * projectDirectory:string * useScriptResolutionRules:bool * keepAssemblyContents: bool * keepAllBackgroundResolutions: bool * maxTimeShareMilliseconds: int64 * tryGetMetadataSnapshot: ILBinaryReader.ILReaderTryGetMetadataSnapshot * suggestNamesForErrors: bool -> Cancellable -/// Generalized Incremental Builder. This is exposed only for unittesting purposes. +/// Generalized Incremental Builder. This is exposed only for unit testing purposes. module internal IncrementalBuild = type INode = abstract Name: string diff --git a/src/fsharp/service/QuickParse.fs b/src/fsharp/service/QuickParse.fs index b431f2557b4..434a0312da1 100644 --- a/src/fsharp/service/QuickParse.fs +++ b/src/fsharp/service/QuickParse.fs @@ -20,10 +20,10 @@ type PartialLongName = /// Position of the last dot. LastDotPos: int option } - /// Empty patial long name. + /// Empty partial long name. static member Empty(endColumn: int) = { QualifyingIdents = []; PartialIdent = ""; EndColumn = endColumn; LastDotPos = None } -/// Methods for cheaply and innacurately parsing F#. +/// Methods for cheaply and inaccurately parsing F#. /// /// These methods are very old and are mostly to do with extracting "long identifier islands" /// A.B.C @@ -58,7 +58,7 @@ module QuickParse = // Utility function that recognizes whether a name is valid active pattern name // Extracts the 'core' part without surrounding bars and checks whether it contains some identifier - // (Note, this doesn't have to be precise, because this is checked by backround compiler, + // (Note, this doesn't have to be precise, because this is checked by background compiler, // but it has to be good enough to distinguish operators and active pattern names) let private isValidActivePatternName (name: string) = @@ -152,7 +152,7 @@ module QuickParse = /// In general, only identifiers composed from upper/lower letters and '.' are supported, but there /// are a couple of explicitly handled exceptions to allow some common scenarios: /// - When the name contains only letters and '|' symbol, it may be an active pattern, so we - /// treat it as a valid identifier - e.g. let ( |Identitiy| ) a = a + /// treat it as a valid identifier - e.g. let ( |Identity| ) a = a /// (but other identifiers that include '|' are not allowed - e.g. '||' operator) /// - It searches for double tick (``) to see if the identifier could be something like ``a b`` /// diff --git a/src/fsharp/service/QuickParse.fsi b/src/fsharp/service/QuickParse.fsi index 5f78dbefd2b..3c2adfd0df8 100644 --- a/src/fsharp/service/QuickParse.fsi +++ b/src/fsharp/service/QuickParse.fsi @@ -19,10 +19,10 @@ type public PartialLongName = /// Position of the last dot. LastDotPos: int option } - /// Empty patial long name. + /// Empty partial long name. static member Empty: endColumn: int -> PartialLongName -/// Methods for cheaply and innacurately parsing F#. +/// Methods for cheaply and inaccurately parsing F#. /// /// These methods are very old and are mostly to do with extracting "long identifier islands" /// A.B.C @@ -57,7 +57,7 @@ module public QuickParse = /// In general, only identifiers composed from upper/lower letters and '.' are supported, but there /// are a couple of explicitly handled exceptions to allow some common scenarios: /// - When the name contains only letters and '|' symbol, it may be an active pattern, so we - /// treat it as a valid identifier - e.g. let ( |Identitiy| ) a = a + /// treat it as a valid identifier - e.g. let ( |Identity| ) a = a /// (but other identifiers that include '|' are not allowed - e.g. '||' operator) /// - It searches for double tick (``) to see if the identifier could be something like ``a b`` /// diff --git a/src/fsharp/service/Reactor.fs b/src/fsharp/service/Reactor.fs index f879e5133f9..b4c487caebf 100755 --- a/src/fsharp/service/Reactor.fs +++ b/src/fsharp/service/Reactor.fs @@ -34,7 +34,7 @@ type Reactor() = let mutable pauseBeforeBackgroundWork = pauseBeforeBackgroundWorkDefault // We need to store the culture for the VS thread that is executing now, - // so that when the reactor picks up a thread from the threadpool we can set the culture + // so that when the reactor picks up a thread from the thread pool we can set the culture let mutable culture = CultureInfo(CultureInfo.CurrentUICulture.Name) let mutable bgOpCts = new CancellationTokenSource() diff --git a/src/fsharp/service/ServiceAnalysis.fs b/src/fsharp/service/ServiceAnalysis.fs index e4f942b657a..d9630ab77a4 100644 --- a/src/fsharp/service/ServiceAnalysis.fs +++ b/src/fsharp/service/ServiceAnalysis.fs @@ -203,7 +203,7 @@ module UnusedOpens = let filterOpenStatements (symbolUses1: FSharpSymbolUse[], symbolUses2: FSharpSymbolUse[]) openStatements = async { // the key is a namespace or module, the value is a list of FSharpSymbolUse range of symbols defined in the - // namespace or module. So, it's just symbol uses ranges groupped by namespace or module where they are _defined_. + // namespace or module. So, it's just symbol uses ranges grouped by namespace or module where they are _defined_. let symbolUsesRangesByDeclaringEntity = Dictionary(entityHash) for symbolUse in symbolUses1 do match symbolUse.Symbol with diff --git a/src/fsharp/service/ServiceAssemblyContent.fs b/src/fsharp/service/ServiceAssemblyContent.fs index 8ceb381225b..4fc27df4adc 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fs +++ b/src/fsharp/service/ServiceAssemblyContent.fs @@ -238,16 +238,16 @@ module AssemblyContentProvider = |> Seq.filter (fun x -> not x.IsInstanceMember && not x.IsPropertyGetterMethod && not x.IsPropertySetterMethod) |> Seq.collect (fun func -> let processIdents fullName idents = - let cleanedIdentes = parent.FixParentModuleSuffix idents + let cleanedIdents = parent.FixParentModuleSuffix idents { FullName = fullName - CleanedIdents = cleanedIdentes + CleanedIdents = cleanedIdents Namespace = ns NearestRequireQualifiedAccessParent = parent.ThisRequiresQualifiedAccess true |> Option.map parent.FixParentModuleSuffix TopRequireQualifiedAccessParent = topRequireQualifiedAccessParent AutoOpenParent = autoOpenParent Symbol = func Kind = fun _ -> EntityKind.FunctionOrValue func.IsActivePattern - UnresolvedSymbol = unresolvedSymbol topRequireQualifiedAccessParent cleanedIdentes fullName } + UnresolvedSymbol = unresolvedSymbol topRequireQualifiedAccessParent cleanedIdents fullName } [ yield! func.TryGetFullDisplayName() |> Option.map (fun fullDisplayName -> processIdents func.FullName (fullDisplayName.Split '.')) @@ -948,8 +948,8 @@ module ParsedInput = let fullIdent = parent @ ident addModule (fullIdent, range) if range.EndLine >= currentLine then - let moduleBodyIdentation = getMinColumn decls |> Option.defaultValue (range.StartColumn + 4) - doRange NestedModule fullIdent range.StartLine moduleBodyIdentation + let moduleBodyIndentation = getMinColumn decls |> Option.defaultValue (range.StartColumn + 4) + doRange NestedModule fullIdent range.StartLine moduleBodyIndentation List.iter (walkSynModuleDecl fullIdent) decls | SynModuleDecl.Open (_, range) -> doRange OpenDeclaration [] range.EndLine (range.StartColumn - 5) | SynModuleDecl.HashDirective (_, range) -> doRange HashDirective [] range.EndLine range.StartColumn @@ -1008,9 +1008,9 @@ module ParsedInput = if ctx.Pos.Line > 1 then // it's an implicit module without any open declarations let line = getLineStr (ctx.Pos.Line - 2) - let isImpliciteTopLevelModule = + let isImplicitTopLevelModule = not (line.StartsWithOrdinal("module") && not (line.EndsWithOrdinal("="))) - if isImpliciteTopLevelModule then 1 else ctx.Pos.Line + if isImplicitTopLevelModule then 1 else ctx.Pos.Line else 1 | ScopeKind.Namespace -> // for namespaces the start line is start line of the first nested entity diff --git a/src/fsharp/service/ServiceAssemblyContent.fsi b/src/fsharp/service/ServiceAssemblyContent.fsi index 0fe14c11444..f9e9699cb7d 100644 --- a/src/fsharp/service/ServiceAssemblyContent.fsi +++ b/src/fsharp/service/ServiceAssemblyContent.fsi @@ -44,7 +44,7 @@ type public AssemblySymbol = { /// Full entity name as it's seen in compiled code (raw FSharpEntity.FullName, FSharpValueOrFunction.FullName). FullName: string /// Entity name parts with removed module suffixes (Ns.M1Module.M2Module.M3.entity -> Ns.M1.M2.M3.entity) - /// and replaced compiled names with display names (FSharpEntity.DisplayName, FSharpValueOrFucntion.DisplayName). + /// and replaced compiled names with display names (FSharpEntity.DisplayName, FSharpValueOrFunction.DisplayName). /// Note: *all* parts are cleaned, not the last one. CleanedIdents: Idents /// `FSharpEntity.Namespace`. @@ -87,10 +87,10 @@ type public EntityCache = /// Performs an operation on the cache in thread safe manner. member Locking : (IAssemblyContentCache -> 'T) -> 'T -/// Lond identifier (i.e. it may contain dots). +/// Long identifier (i.e. it may contain dots). type public StringLongIdent = string -/// Helper data structure representing a symbol, sutable for implementing unresolved identifiers resolution code fixes. +/// Helper data structure representing a symbol, suitable for implementing unresolved identifiers resolution code fixes. type public Entity = { /// Full name, relative to the current scope. FullRelativeName: StringLongIdent @@ -149,7 +149,7 @@ module public ParsedInput = /// Returns `InsertContext` based on current position and symbol idents. val findNearestPointToInsertOpenDeclaration : currentLine: int -> ast: Ast.ParsedInput -> entity: Idents -> insertionPoint: OpenStatementInsertionPoint -> InsertContext - /// Returns lond identifier at position. + /// Returns long identifier at position. val getLongIdentAt : ast: Ast.ParsedInput -> pos: Range.pos -> Ast.LongIdent option /// Corrects insertion line number based on kind of scope and text surrounding the insertion point. diff --git a/src/fsharp/service/ServiceLexing.fs b/src/fsharp/service/ServiceLexing.fs index 2deb0073598..c37ea56d903 100644 --- a/src/fsharp/service/ServiceLexing.fs +++ b/src/fsharp/service/ServiceLexing.fs @@ -454,7 +454,7 @@ module internal LexerStateEncoding = let decodeLexInt (state: FSharpTokenizerLexState) = - let tag, n1, p1, ifd, lightSyntaxStatusInital = decodeLexCont state + let tag, n1, p1, ifd, lightSyntaxStatusInitial = decodeLexCont state let lexcont = match tag with | FSharpTokenizerColorState.Token -> LexCont.Token ifd @@ -471,7 +471,7 @@ module internal LexerStateEncoding = | FSharpTokenizerColorState.EndLineThenSkip -> LexCont.EndLine(LexerEndlineContinuation.Skip(ifd, n1, mkRange "file" p1 p1)) | FSharpTokenizerColorState.EndLineThenToken -> LexCont.EndLine(LexerEndlineContinuation.Token ifd) | _ -> LexCont.Token [] - lightSyntaxStatusInital, lexcont + lightSyntaxStatusInitial, lexcont let callLexCont lexcont args skip lexbuf = let argsWithIfDefs ifd = @@ -500,7 +500,7 @@ module internal LexerStateEncoding = //---------------------------------------------------------------------------- // Information beyond just tokens that can be derived by looking at just a single line. -// For example metacommands like #load. +// For example meta commands like #load. type SingleLineTokenState = | BeforeHash = 0 | NoFurtherMatchPossible = 1 @@ -595,11 +595,11 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf, use unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse use unwindEL = PushErrorLoggerPhaseUntilUnwind (fun _ -> DiscardErrorsLogger) - let lightSyntaxStatusInital, lexcontInitial = LexerStateEncoding.decodeLexInt lexintInitial - let lightSyntaxStatus = LightSyntaxStatus(lightSyntaxStatusInital, false) + let lightSyntaxStatusInitial, lexcontInitial = LexerStateEncoding.decodeLexInt lexintInitial + let lightSyntaxStatus = LightSyntaxStatus(lightSyntaxStatusInitial, false) // Build the arguments to the lexer function - let lexargs = if lightSyntaxStatusInital then lexArgsLightOn else lexArgsLightOff + let lexargs = if lightSyntaxStatusInitial then lexArgsLightOn else lexArgsLightOff let GetTokenWithPosition lexcontInitial = // Column of token @@ -618,7 +618,7 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf, try if (tokenStack.Count > 0) then true, tokenStack.Pop() else - // Choose which lexer entrypoint to call and call it + // Choose which lexer entry point to call and call it let token = LexerStateEncoding.callLexCont lexcontInitial lexargs skip lexbuf let leftc, rightc = ColumnsOfCurrentToken() @@ -722,8 +722,8 @@ type FSharpLineTokenizer(lexbuf: UnicodeLexing.Lexbuf, // Peek at the next token let isCached, (nextToken, _, rightc) = GetTokenWithPosition lexcontInitial match nextToken with - | IDENT possibleMetacommand -> - match fsx, possibleMetacommand with + | IDENT possibleMetaCommand -> + match fsx, possibleMetaCommand with // These are for script (.fsx and .fsscript) files. | true, "r" | true, "reference" diff --git a/src/fsharp/service/ServiceLexing.fsi b/src/fsharp/service/ServiceLexing.fsi index 85e18f171c4..2ee5dfacaa2 100755 --- a/src/fsharp/service/ServiceLexing.fsi +++ b/src/fsharp/service/ServiceLexing.fsi @@ -15,7 +15,7 @@ type FSharpTokenizerLexState = static member Initial : FSharpTokenizerLexState member Equals : FSharpTokenizerLexState -> bool -/// Represents stable information for the state of the laxing engine at the end of a line +/// Represents stable information for the state of the lexing engine at the end of a line type FSharpTokenizerColorState = | Token = 1 | IfDefSkip = 3 @@ -32,7 +32,7 @@ type FSharpTokenizerColorState = | TripleQuoteStringInComment = 14 | InitialState = 0 -/// Gives an indicattion of the color class to assign to the token an IDE +/// Gives an indication of the color class to assign to the token an IDE type FSharpTokenColorKind = | Default = 0 | Text = 0 diff --git a/src/fsharp/service/ServiceNavigation.fs b/src/fsharp/service/ServiceNavigation.fs index 0640e9ef06b..3578543b65b 100755 --- a/src/fsharp/service/ServiceNavigation.fs +++ b/src/fsharp/service/ServiceNavigation.fs @@ -127,13 +127,13 @@ module NavigationImpl = FSharpNavigationDeclarationItem.Create(id.idText, kind, baseGlyph, m, m, false, enclosingEntityKind, isAbstract, access), (addItemName(id.idText)) // Process let-binding - let processBinding isMember enclosingEntityKind isAbstract (Binding(_, _, _, _, _, _, SynValData(memebrOpt, _, _), synPat, _, synExpr, _, _)) = + let processBinding isMember enclosingEntityKind isAbstract (Binding(_, _, _, _, _, _, SynValData(memberOpt, _, _), synPat, _, synExpr, _, _)) = let m = match synExpr with | SynExpr.Typed (e, _, _) -> e.Range // fix range for properties with type annotations | _ -> synExpr.Range - match synPat, memebrOpt with + match synPat, memberOpt with | SynPat.LongIdent(longDotId=LongIdentWithDots(lid,_); accessibility=access), Some(flags) when isMember -> let icon, kind = match flags.MemberKind with @@ -632,7 +632,7 @@ module NavigateTo = | SynMemberSig.Inherit _ | SynMemberSig.Interface _ -> () - and walkImplFileInpit (ParsedImplFileInput (fileName = fileName; modules = moduleOrNamespaceList)) = + and walkImplFileInput (ParsedImplFileInput (fileName = fileName; modules = moduleOrNamespaceList)) = let container = { Type = ContainerType.File; Name = fileName } for item in moduleOrNamespaceList do walkSynModuleOrNamespace item container @@ -732,7 +732,7 @@ module NavigateTo = match parsedInput with | ParsedInput.SigFile input -> walkSigFileInput input - | ParsedInput.ImplFile input -> walkImplFileInpit input + | ParsedInput.ImplFile input -> walkImplFileInput input result.ToArray() diff --git a/src/fsharp/service/ServiceStructure.fs b/src/fsharp/service/ServiceStructure.fs index 1bf31e27cf6..56f2312da46 100644 --- a/src/fsharp/service/ServiceStructure.fs +++ b/src/fsharp/service/ServiceStructure.fs @@ -47,7 +47,7 @@ module Structure = | [] -> range0 | head :: _ -> Range.startToEnd head.idRange (List.last longId).idRange - /// Caclulate the range of the provided type arguments (<'a, ..., 'z>) + /// Calculate the range of the provided type arguments (<'a, ..., 'z>) /// or return the range `other` when `typeArgs` = [] let rangeOfTypeArgsElse other (typeArgs:SynTyparDecl list) = match typeArgs with @@ -77,7 +77,7 @@ module Structure = | Below | Same - /// Tag to identify the constuct that can be stored alongside its associated ranges + /// Tag to identify the construct that can be stored alongside its associated ranges [] type Scope = | Open @@ -177,7 +177,7 @@ module Structure = | Comment -> "Comment" | XmlDocComment -> "XmlDocComment" - /// Stores the range for a construct, the sub-range that should be collapsed for outlinging, + /// Stores the range for a construct, the sub-range that should be collapsed for outlining, /// a tag for the construct type, and a tag for the collapse style [] type ScopeRange = @@ -204,7 +204,7 @@ module Structure = let getOutliningRanges (sourceLines: string[]) (parsedInput: ParsedInput) = let acc = ResizeArray() - /// Validation function to ensure that ranges yielded for outlinging span 2 or more lines + /// Validation function to ensure that ranges yielded for outlining span 2 or more lines let inline rcheck scope collapse (fullRange: range) (collapseRange: range) = if fullRange.StartLine <> fullRange.EndLine then acc.Add { Scope = scope @@ -281,7 +281,7 @@ module Structure = if ExprAtomicFlag.NonAtomic=atomicFlag && (not isInfix) && (function SynExpr.Ident _ -> true | _ -> false) funcExpr && (function SynExpr.CompExpr _ -> false | _ -> true ) argExpr then - // if the argExrp is a computation expression another match will handle the outlining + // if the argExpr is a computation expression another match will handle the outlining // these cases must be removed to prevent creating unnecessary tags for the same scope let collapse = Range.endToEnd funcExpr.Range r rcheck Scope.SpecialFunc Collapse.Below r collapse @@ -624,7 +624,7 @@ module Structure = collectOpens decls List.iter parseDeclaration decls - /// Determine if a line is a single line or xml docummentation comment + /// Determine if a line is a single line or xml documentation comment let (|Comment|_|) (line: string) = if line.StartsWithOrdinal("///") then Some XmlDoc elif line.StartsWithOrdinal("//") then Some SingleLine diff --git a/src/fsharp/service/ServiceStructure.fsi b/src/fsharp/service/ServiceStructure.fsi index ef90f4627ea..4eeefe529fd 100644 --- a/src/fsharp/service/ServiceStructure.fsi +++ b/src/fsharp/service/ServiceStructure.fsi @@ -15,7 +15,7 @@ module public Structure = | Below | Same - /// Tag to identify the constuct that can be stored alongside its associated ranges + /// Tag to identify the construct that can be stored alongside its associated ranges [] type Scope = | Open diff --git a/src/fsharp/service/ServiceUntypedParse.fs b/src/fsharp/service/ServiceUntypedParse.fs index 84c8947d13d..c087fe48a83 100755 --- a/src/fsharp/service/ServiceUntypedParse.fs +++ b/src/fsharp/service/ServiceUntypedParse.fs @@ -596,10 +596,10 @@ module UntypedParseImpl = AstTraversal.Traverse(pos, parseTree, walker) // Given a cursor position here: - // f(x) . iden + // f(x) . ident // ^ // walk the AST to find the position here: - // f(x) . iden + // f(x) . ident // ^ // On success, return Some (thatPos, boolTrueIfCursorIsAfterTheDotButBeforeTheIdentifier) // If there's no dot, return None, so for example diff --git a/src/fsharp/service/service.fs b/src/fsharp/service/service.fs index 7eac7390c29..97a35f135bb 100644 --- a/src/fsharp/service/service.fs +++ b/src/fsharp/service/service.fs @@ -131,7 +131,7 @@ module Helpers = && FSharpProjectOptions.UseSameProject(o1,o2) module CompileHelpers = - let mkCompilationErorHandlers() = + let mkCompilationErrorHandlers() = let errors = ResizeArray<_>() let errorSink isError exn = @@ -164,7 +164,7 @@ module CompileHelpers = /// Compile using the given flags. Source files names are resolved via the FileSystem API. The output file must be given by a -o flag. let compileFromArgs (ctok, argv: string[], legacyReferenceResolver, tcImportsCapture, dynamicAssemblyCreator) = - let errors, errorLogger, loggerProvider = mkCompilationErorHandlers() + let errors, errorLogger, loggerProvider = mkCompilationErrorHandlers() let result = tryCompile errorLogger (fun exiter -> mainCompile (ctok, argv, legacyReferenceResolver, (*bannerAlreadyPrinted*)true, ReduceMemoryFlag.Yes, CopyFSharpCoreFlag.No, exiter, loggerProvider, tcImportsCapture, dynamicAssemblyCreator) ) @@ -173,7 +173,7 @@ module CompileHelpers = let compileFromAsts (ctok, legacyReferenceResolver, asts, assemblyName, outFile, dependencies, noframework, pdbFile, executable, tcImportsCapture, dynamicAssemblyCreator) = - let errors, errorLogger, loggerProvider = mkCompilationErorHandlers() + let errors, errorLogger, loggerProvider = mkCompilationErrorHandlers() let executable = defaultArg executable true let target = if executable then CompilerTarget.ConsoleExe else CompilerTarget.Dll @@ -205,7 +205,7 @@ module CompileHelpers = TypeDefs = ilxMainModule.TypeDefs.AsList |> List.filter (fun td -> not (isTypeNameForGlobalFunctions td.Name)) |> mkILTypeDefs Resources=mkILResources [] } - // The function used to resolve typees while emitting the code + // The function used to resolve types while emitting the code let assemblyResolver s = match tcImportsRef.Value.Value.TryFindExistingFullyQualifiedPathByExactAssemblyRef (ctok, s) with | Some res -> Some (Choice1Of2 res) @@ -385,7 +385,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC areSame=AreSameForChecking3, areSimilar=AreSubsumable3) - /// Holds keys for files being currently checked. It's used to prevent checking same file in parallel (interleaving chunck queued to Reactor). + /// Holds keys for files being currently checked. It's used to prevent checking same file in parallel (interleaving chunk queued to Reactor). let beingCheckedFileTable = ConcurrentDictionary (HashIdentity.FromFunctions @@ -687,7 +687,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC tcErrors, reactorOps, keepAssemblyContents, - Option.get tcProj.LastestCcuSigForFile, + Option.get tcProj.LatestCcuSigForFile, tcProj.TcState.Ccu, tcProj.TcImports, tcProj.TcEnvAtEnd.AccessRights, @@ -1167,7 +1167,7 @@ type FSharpChecker(legacyReferenceResolver, // Apply command-line arguments and collect more source files if they are in the arguments let sourceFilesNew = ApplyCommandLineArgs(tcConfigBuilder, initialSourceFiles, argv) - FSharpParsingOptions.FromTcConfigBuidler(tcConfigBuilder, Array.ofList sourceFilesNew, isInteractive), errorScope.Diagnostics + FSharpParsingOptions.FromTcConfigBuilder(tcConfigBuilder, Array.ofList sourceFilesNew, isInteractive), errorScope.Diagnostics member ic.GetParsingOptionsFromCommandLineArgs(argv, ?isInteractive: bool) = ic.GetParsingOptionsFromCommandLineArgs([], argv, ?isInteractive=isInteractive) diff --git a/src/fsharp/symbols/Exprs.fs b/src/fsharp/symbols/Exprs.fs index 7941a6be577..16ada4ec575 100644 --- a/src/fsharp/symbols/Exprs.fs +++ b/src/fsharp/symbols/Exprs.fs @@ -339,11 +339,11 @@ module FSharpExprConvert = and ConvExpr cenv env expr = Mk2 cenv expr (ConvExprPrim cenv env expr) - and ConvExprLinear cenv env expr contf = - ConvExprPrimLinear cenv env expr (fun exprR -> contf (Mk2 cenv expr exprR)) + and ConvExprLinear cenv env expr contF = + ConvExprPrimLinear cenv env expr (fun exprR -> contF (Mk2 cenv expr exprR)) // Tail recursive function to process the subset of expressions considered "linear" - and ConvExprPrimLinear cenv env expr contf = + and ConvExprPrimLinear cenv env expr contF = match expr with // Large lists @@ -352,15 +352,15 @@ module FSharpExprConvert = let typR = ConvType cenv (mkAppTy ucref.TyconRef tyargs) let e1R = ConvExpr cenv env e1 // tail recursive - ConvExprLinear cenv env e2 (contf << (fun e2R -> E.NewUnionCase(typR, mkR, [e1R; e2R]) )) + ConvExprLinear cenv env e2 (contF << (fun e2R -> E.NewUnionCase(typR, mkR, [e1R; e2R]) )) // Large sequences of let bindings | Expr.Let (bind, body, _, _) -> match ConvLetBind cenv env bind with - | None, env -> ConvExprPrimLinear cenv env body contf + | None, env -> ConvExprPrimLinear cenv env body contF | Some bindR, env -> // tail recursive - ConvExprLinear cenv env body (contf << (fun bodyR -> E.Let(bindR, bodyR))) + ConvExprLinear cenv env body (contF << (fun bodyR -> E.Let(bindR, bodyR))) // Remove initialization checks // Remove static initialization counter updates @@ -372,23 +372,23 @@ module FSharpExprConvert = | Expr.Sequential (ObjectInitializationCheck cenv.g, x1, NormalSeq, _, _) | Expr.Sequential (StaticInitializationCount, x1, NormalSeq, _, _) | Expr.Sequential (StaticInitializationCheck, x1, NormalSeq, _, _) -> - ConvExprPrim cenv env x1 |> contf + ConvExprPrim cenv env x1 |> contF // Large sequences of sequential code | Expr.Sequential (e1, e2, NormalSeq, _, _) -> let e1R = ConvExpr cenv env e1 // tail recursive - ConvExprLinear cenv env e2 (contf << (fun e2R -> E.Sequential(e1R, e2R))) + ConvExprLinear cenv env e2 (contF << (fun e2R -> E.Sequential(e1R, e2R))) | Expr.Sequential (x0, x1, ThenDoSeq, _, _) -> E.Sequential(ConvExpr cenv env x0, ConvExpr cenv env x1) | ModuleValueOrMemberUse cenv.g (vref, vFlags, _f, _fty, tyargs, curriedArgs) when (nonNil tyargs || nonNil curriedArgs) && vref.IsMemberOrModuleBinding -> - ConvModuleValueOrMemberUseLinear cenv env (expr, vref, vFlags, tyargs, curriedArgs) contf + ConvModuleValueOrMemberUseLinear cenv env (expr, vref, vFlags, tyargs, curriedArgs) contF | Expr.Match (_spBind, m, dtree, tgs, _, retTy) -> let dtreeR = ConvDecisionTree cenv env retTy dtree m // tailcall - ConvTargetsLinear cenv env (List.ofArray tgs) (contf << fun (targetsR: _ list) -> + ConvTargetsLinear cenv env (List.ofArray tgs) (contF << fun (targetsR: _ list) -> let (|E|) (x: FSharpExpr) = x.E // If the match is really an "if-then-else" then return it as such. @@ -397,11 +397,11 @@ module FSharpExprConvert = | _ -> E.DecisionTree(dtreeR, targetsR)) | _ -> - ConvExprPrim cenv env expr |> contf + ConvExprPrim cenv env expr |> contF /// A nasty function copied from creflect.fs. Made nastier by taking a continuation to process the /// arguments to the call in a tail-recursive fashion. - and ConvModuleValueOrMemberUseLinear (cenv: SymbolEnv) env (expr: Expr, vref, vFlags, tyargs, curriedArgs) contf = + and ConvModuleValueOrMemberUseLinear (cenv: SymbolEnv) env (expr: Expr, vref, vFlags, tyargs, curriedArgs) contF = let m = expr.Range let (numEnclTypeArgs, _, isNewObj, _valUseFlags, _isSelfInit, takesInstanceArg, _isPropGet, _isPropSet) = @@ -444,7 +444,7 @@ module FSharpExprConvert = let expr, exprty = AdjustValForExpectedArity cenv.g m vref vFlags topValInfo let splitCallExpr = MakeApplicationAndBetaReduce cenv.g (expr, exprty, [tyargs], curriedArgs, m) // tailcall - ConvExprPrimLinear cenv env splitCallExpr contf + ConvExprPrimLinear cenv env splitCallExpr contF else let curriedArgs, laterArgs = List.splitAt curriedArgInfos.Length curriedArgs @@ -459,8 +459,8 @@ module FSharpExprConvert = let contf2 = match laterArgs with - | [] -> contf - | _ -> (fun subCallR -> (subCallR, laterArgs) ||> List.fold (fun fR arg -> E.Application (Mk2 cenv arg fR, [], [ConvExpr cenv env arg])) |> contf) + | [] -> contF + | _ -> (fun subCallR -> (subCallR, laterArgs) ||> List.fold (fun fR arg -> E.Application (Mk2 cenv arg fR, [], [ConvExpr cenv env arg])) |> contF) if isMember then let callArgs = (objArgs :: untupledCurriedArgs) |> List.concat @@ -827,7 +827,7 @@ module FSharpExprConvert = let typR = ConvType cenv (mkAppTy tycr tyargs) E.UnionCaseTag(ConvExpr cenv env arg1, typR) - | TOp.TraitCall (TTrait(tys, nm, memFlags, argtys, _rty, _colution)), _, _ -> + | TOp.TraitCall (TTrait(tys, nm, memFlags, argtys, _rty, _solution)), _, _ -> let tysR = ConvTypes cenv tys let tyargsR = ConvTypes cenv tyargs let argtysR = ConvTypes cenv argtys @@ -849,7 +849,7 @@ module FSharpExprConvert = // 'let v = isinst e in .... if nonnull v then ...v .... ' // construct arising out the compilation of pattern matching. We decode these back to the form // 'if istype e then ...unbox e .... ' - // It's bit annoying that pattern matching does this tranformation. Like all premature optimization we pay a + // It's bit annoying that pattern matching does this transformation. Like all premature optimization we pay a // cost here to undo it. | Expr.Op (TOp.ILAsm ([ I_isinst _ ], _), [ty], [e], _) -> None, env.BindIsInstVal bind.Var (ty, e) @@ -951,7 +951,7 @@ module FSharpExprConvert = else let valR = ConvExpr cenv env callArgs.Head E.ValueSet (m, valR) - | _ -> failwith "Failed to resolve module value unambigously" + | _ -> failwith "Failed to resolve module value unambiguously" else failwith "Failed to resolve module member" | _ -> @@ -1077,7 +1077,7 @@ module FSharpExprConvert = with e -> failwithf "An IL call to '%s' could not be resolved: %s" (ilMethRef.ToString()) e.Message - and ConvObjectModelCallLinear cenv env (isNewObj, v: FSharpMemberOrFunctionOrValue, enclTyArgs, methTyArgs, callArgs) contf = + and ConvObjectModelCallLinear cenv env (isNewObj, v: FSharpMemberOrFunctionOrValue, enclTyArgs, methTyArgs, callArgs) contF = let enclTyArgsR = ConvTypes cenv enclTyArgs let methTyArgsR = ConvTypes cenv methTyArgs let obj, callArgs = @@ -1089,7 +1089,7 @@ module FSharpExprConvert = None, callArgs let objR = Option.map (ConvLValueExpr cenv env) obj // tailcall - ConvExprsLinear cenv env callArgs (contf << fun callArgsR -> + ConvExprsLinear cenv env callArgs (contF << fun callArgsR -> if isNewObj then E.NewObject(v, enclTyArgsR, callArgsR) else @@ -1098,21 +1098,21 @@ module FSharpExprConvert = and ConvExprs cenv env args = List.map (ConvExpr cenv env) args - // Process a list of expressions in a tail-recursive way. Identical to "ConvExprs" but the result is eventually passed to contf. - and ConvExprsLinear cenv env args contf = + // Process a list of expressions in a tail-recursive way. Identical to "ConvExprs" but the result is eventually passed to contF. + and ConvExprsLinear cenv env args contF = match args with - | [] -> contf [] - | [arg] -> ConvExprLinear cenv env arg (fun argR -> contf [argR]) - | arg :: rest -> ConvExprLinear cenv env arg (fun argR -> ConvExprsLinear cenv env rest (fun restR -> contf (argR :: restR))) + | [] -> contF [] + | [arg] -> ConvExprLinear cenv env arg (fun argR -> contF [argR]) + | arg :: rest -> ConvExprLinear cenv env arg (fun argR -> ConvExprsLinear cenv env rest (fun restR -> contF (argR :: restR))) - and ConvTargetsLinear cenv env tgs contf = + and ConvTargetsLinear cenv env tgs contF = match tgs with - | [] -> contf [] + | [] -> contF [] | TTarget(vars, rhs, _) :: rest -> let varsR = (List.rev vars) |> List.map (ConvVal cenv) ConvExprLinear cenv env rhs (fun targetR -> ConvTargetsLinear cenv env rest (fun restR -> - contf ((varsR, targetR) :: restR))) + contF ((varsR, targetR) :: restR))) and ConvValRef cenv env m (vref: ValRef) = let v = vref.Deref diff --git a/src/fsharp/symbols/Exprs.fsi b/src/fsharp/symbols/Exprs.fsi index fd5d88c0225..96c12024cc8 100644 --- a/src/fsharp/symbols/Exprs.fsi +++ b/src/fsharp/symbols/Exprs.fsi @@ -89,7 +89,7 @@ module public BasicPatterns = /// Matches expressions which are type abstractions val (|TypeLambda|_|) : FSharpExpr -> (FSharpGenericParameter list * FSharpExpr) option - /// Matches expressions with a decision expression, each branch of which ends in DecisionTreeSuccess pasing control and values to one of the targets. + /// Matches expressions with a decision expression, each branch of which ends in DecisionTreeSuccess passing control and values to one of the targets. val (|DecisionTree|_|) : FSharpExpr -> (FSharpExpr * (FSharpMemberOrFunctionOrValue list * FSharpExpr) list) option /// Special expressions at the end of a conditional decision structure in the decision expression node of a DecisionTree . diff --git a/src/fsharp/symbols/SymbolHelpers.fs b/src/fsharp/symbols/SymbolHelpers.fs index b1c46d9bd72..cf87b0b8f71 100644 --- a/src/fsharp/symbols/SymbolHelpers.fs +++ b/src/fsharp/symbols/SymbolHelpers.fs @@ -117,7 +117,7 @@ type ErrorScope() = /// may hit internal compiler failures. /// /// In some calling cases, we get a chance to report the error as part of user text. For example - /// if there is a "msising assembly" error while formatting the text of the description of an + /// if there is a "missing assembly" error while formatting the text of the description of an /// autocomplete, then the error message is shown in replacement of the text (rather than crashing Visual /// Studio, or swallowing the exception completely) static member Protect<'a> (m: range) (f: unit->'a) (err: string->'a): 'a = @@ -212,7 +212,7 @@ type FSharpXmlDoc = type FSharpToolTipElementData<'T> = { MainDescription: 'T XmlDoc: FSharpXmlDoc - /// typar insantiation text, to go after xml + /// typar instantiation text, to go after xml TypeMapping: 'T list Remarks: 'T option ParamName : string option } @@ -762,7 +762,7 @@ module internal SymbolHelpers = | Item.Property(_, pi1s), Item.Property(_, pi2s) -> List.zip pi1s pi2s |> List.forall(fun (pi1, pi2) -> PropInfo.PropInfosUseIdenticalDefinitions pi1 pi2) | Item.Event evt1, Item.Event evt2 -> - EventInfo.EventInfosUseIdenticalDefintions evt1 evt2 + EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2 | Item.AnonRecdField(anon1, _, i1, _), Item.AnonRecdField(anon2, _, i2, _) -> Tastops.anonInfoEquiv anon1 anon2 && i1 = i2 | Item.CtorGroup(_, meths1), Item.CtorGroup(_, meths2) -> @@ -1301,7 +1301,7 @@ module internal SymbolHelpers = #endif - /// Get the "F1 Keyword" associated with an item, for looking up documentatio help indexes on the web + /// Get the "F1 Keyword" associated with an item, for looking up documentation help indexes on the web let rec GetF1Keyword (g: TcGlobals) item = let getKeywordForMethInfo (minfo : MethInfo) = diff --git a/src/fsharp/symbols/SymbolHelpers.fsi b/src/fsharp/symbols/SymbolHelpers.fsi index 984654c461d..e6ece6fa2ca 100755 --- a/src/fsharp/symbols/SymbolHelpers.fsi +++ b/src/fsharp/symbols/SymbolHelpers.fsi @@ -64,7 +64,7 @@ type public Layout = Internal.Utilities.StructuredFormat.Layout type public FSharpToolTipElementData<'T> = { MainDescription: 'T XmlDoc: FSharpXmlDoc - /// typar insantiation text, to go after xml + /// typar instantiation text, to go after xml TypeMapping: 'T list /// Extra text, goes at the end Remarks: 'T option diff --git a/src/fsharp/symbols/Symbols.fs b/src/fsharp/symbols/Symbols.fs index fcfe2c085fb..add09769d6a 100644 --- a/src/fsharp/symbols/Symbols.fs +++ b/src/fsharp/symbols/Symbols.fs @@ -1954,7 +1954,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = // Note, returning "public" is wrong for IL members that are private match d with | E e -> - // For IL events, we get an approximate accessiblity that at least reports "internal" as "internal" and "private" as "private" + // For IL events, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private" let access = match e with | ILEvent ileinfo -> @@ -1965,7 +1965,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = FSharpAccessibility access | P p -> - // For IL properties, we get an approximate accessiblity that at least reports "internal" as "internal" and "private" as "private" + // For IL properties, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private" let access = match p with | ILProp ilpinfo -> @@ -1977,13 +1977,13 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = | M m | C m -> - // For IL methods, we get an approximate accessiblity that at least reports "internal" as "internal" and "private" as "private" + // For IL methods, we get an approximate accessibility that at least reports "internal" as "internal" and "private" as "private" let access = match m with | ILMeth (_, x, _) -> getApproxFSharpAccessibilityOfMember x.DeclaringTyconRef x.RawMetadata.Access | _ -> taccessPublic - FSharpAccessibility(access, isProtected=m.IsProtectedAccessiblity) + FSharpAccessibility(access, isProtected=m.IsProtectedAccessibility) | V v -> FSharpAccessibility(v.Accessibility) @@ -2010,7 +2010,7 @@ and FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) = match other with | :? FSharpMemberOrFunctionOrValue as other -> match d, other.Data with - | E evt1, E evt2 -> EventInfo.EventInfosUseIdenticalDefintions evt1 evt2 + | E evt1, E evt2 -> EventInfo.EventInfosUseIdenticalDefinitions evt1 evt2 | P p1, P p2 -> PropInfo.PropInfosUseIdenticalDefinitions p1 p2 | M m1, M m2 | C m1, C m2 -> MethInfo.MethInfosUseIdenticalDefinitions m1 m2 diff --git a/src/fsharp/symbols/Symbols.fsi b/src/fsharp/symbols/Symbols.fsi index 60c3cecedd3..19df3cd26a6 100644 --- a/src/fsharp/symbols/Symbols.fsi +++ b/src/fsharp/symbols/Symbols.fsi @@ -87,7 +87,7 @@ type [] public FSharpSymbol = /// Return true if two symbols are effectively the same when referred to in F# source code text. /// This sees through signatures (a symbol in a signature will be considered effectively the same as - /// the matching symbol in an implementation). In addition, other equivalances are applied + /// the matching symbol in an implementation). In addition, other equivalences are applied /// when the same F# source text implies the same declaration name - for example, constructors /// are considered to be effectively the same symbol as the corresponding type definition. /// diff --git a/src/fsharp/tast.fs b/src/fsharp/tast.fs index 6e063cd8314..a122bfe146b 100644 --- a/src/fsharp/tast.fs +++ b/src/fsharp/tast.fs @@ -600,7 +600,7 @@ type EntityOptionalData = /// Indicates how visible is the entity is. // MUTABILITY: only for unpickle linkage - mutable entity_accessiblity: Accessibility + mutable entity_accessibility: Accessibility /// Field used when the 'tycon' is really an exception definition // @@ -678,7 +678,7 @@ and /// Represents a type definition, exception definition, module definition or entity_xmldocsig = "" entity_tycon_abbrev = None entity_tycon_repr_accessibility = TAccess [] - entity_accessiblity = TAccess [] + entity_accessibility = TAccess [] entity_exn_info = TExnNone } /// The name of the namespace, module or type, possibly with mangling, e.g. List`1, List or FailureException @@ -884,7 +884,7 @@ and /// Represents a type definition, exception definition, module definition or /// Get the value representing the accessibility of an F# type definition or module. member x.Accessibility = match x.entity_opt_data with - | Some optData -> optData.entity_accessiblity + | Some optData -> optData.entity_accessibility | _ -> TAccess [] /// Indicates the type prefers the "tycon" syntax for display etc. @@ -1049,7 +1049,7 @@ and /// Represents a type definition, exception definition, module definition or entity_xmldocsig = tg.entity_xmldocsig entity_tycon_abbrev = tg.entity_tycon_abbrev entity_tycon_repr_accessibility = tg.entity_tycon_repr_accessibility - entity_accessiblity = tg.entity_accessiblity + entity_accessibility = tg.entity_accessibility entity_exn_info = tg.entity_exn_info } | None -> () @@ -1235,8 +1235,8 @@ and /// Represents a type definition, exception definition, module definition or let rec top racc p = match p with | [] -> ILTypeRef.Create(sref, [], textOfPath (List.rev (item :: racc))) - | (h, istype) :: t -> - match istype with + | (h, isType) :: t -> + match isType with | FSharpModuleWithSuffix | ModuleOrType -> let outerTypeName = (textOfPath (List.rev (h :: racc))) ILTypeRef.Create(sref, (outerTypeName :: List.map (fun (nm, _) -> nm) t), item) @@ -1910,7 +1910,7 @@ and [] cacheOptRef tyconsByAccessNamesCache (fun () -> LayeredMultiMap.Empty.AddAndMarkAsCollapsible (mtyp.TypeAndExceptionDefinitions |> List.toArray |> Array.collect (fun (tc: Tycon) -> KeyTyconByAccessNames tc.LogicalName tc))) - // REVIEW: we can remove this lookup and use AllEntitiedByMangledName instead? + // REVIEW: we can remove this lookup and use AllEntitiesByMangledName instead? member mtyp.TypesByMangledName = let addTyconByMangledName (x: Tycon) tab = NameMap.add x.LogicalName x tab cacheOptRef tyconsByMangledNameCache (fun () -> @@ -2090,7 +2090,7 @@ and Construct = entity_opt_data = match kind, access with | TyparKind.Type, TAccess [] -> None - | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_accessiblity = access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_accessibility = access } } #endif static member NewModuleOrNamespace cpath access (id: Ident) xml attribs mtype = @@ -2112,7 +2112,7 @@ and Construct = entity_opt_data = match xml, access with | XmlDoc [||], TAccess [] -> None - | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = xml; entity_tycon_repr_accessibility = access; entity_accessiblity = access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = xml; entity_tycon_repr_accessibility = access; entity_accessibility = access } } and [] @@ -2398,7 +2398,7 @@ and [] TraitConstraintInfo = - /// TTrait(tys, nm, memFlags, argtys, rty, colution) + /// TTrait(tys, nm, memFlags, argtys, rty, solution) /// /// Indicates the signature of a member constraint. Contains a mutable solution cell /// to store the inferred solution of the constraint. @@ -5733,7 +5733,7 @@ let NewExn cpath (id: Ident) access repr attribs doc = entity_opt_data = match doc, access, repr with | XmlDoc [||], TAccess [], TExnNone -> None - | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = doc; entity_accessiblity = access; entity_tycon_repr_accessibility = access; entity_exn_info = repr } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_xmldoc = doc; entity_accessibility = access; entity_tycon_repr_accessibility = access; entity_exn_info = repr } } /// Create a new TAST RecdField node for an F# class, struct or record field let NewRecdField stat konst id nameGenerated ty isMutable isVolatile pattribs fattribs docOption access secret = @@ -5771,7 +5771,7 @@ let NewTycon (cpath, nm, m, access, reprAccess, kind, typars, docOption, usesPre entity_opt_data = match kind, docOption, reprAccess, access with | TyparKind.Type, XmlDoc [||], TAccess [], TAccess [] -> None - | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_xmldoc = docOption; entity_tycon_repr_accessibility = reprAccess; entity_accessiblity=access } } + | _ -> Some { Entity.NewEmptyEntityOptData() with entity_kind = kind; entity_xmldoc = docOption; entity_tycon_repr_accessibility = reprAccess; entity_accessibility=access } } let NewILTycon nlpath (nm, m) tps (scoref: ILScopeRef, enc, tdef: ILTypeDef) mtyp = @@ -5871,7 +5871,7 @@ let CombineCcuContentFragments m l = let entities = [ for e1 in mty1.AllEntities do match tab2.TryGetValue e1.LogicalName with - | true, e2 -> yield CombineEntites path e1 e2 + | true, e2 -> yield CombineEntities path e1 e2 | _ -> yield e1 for e2 in mty2.AllEntities do match tab1.TryGetValue e2.LogicalName with @@ -5888,7 +5888,7 @@ let CombineCcuContentFragments m l = | _-> error(Error(FSComp.SR.tastTwoModulesWithSameNameInAssembly(textOfPath path), m)) - and CombineEntites path (entity1: Entity) (entity2: Entity) = + and CombineEntities path (entity1: Entity) (entity2: Entity) = match entity1.IsModuleOrNamespace, entity2.IsModuleOrNamespace with | true, true -> diff --git a/src/utils/CompilerLocationUtils.fs b/src/utils/CompilerLocationUtils.fs index 95aa5c5a31e..097b8d92e60 100644 --- a/src/utils/CompilerLocationUtils.fs +++ b/src/utils/CompilerLocationUtils.fs @@ -124,7 +124,7 @@ module internal FSharpEnvironment = let tryRegKey(subKey:string) = - //if we are runing on mono simply return None + //if we are running on mono simply return None // GetDefaultRegistryStringValueViaDotNet will result in an access denied by default, // and Get32BitRegistryStringValueViaPInvoke will fail due to Advapi32.dll not existing if runningOnMono then None else @@ -188,7 +188,7 @@ module internal FSharpEnvironment = // Check for an app.config setting to redirect the default compiler location // Like fsharp-compiler-location try - // FSharp.Compiler support setting an appkey for compiler location. I've never seen this used. + // FSharp.Compiler support setting an appKey for compiler location. I've never seen this used. let result = tryAppConfig "fsharp-compiler-location" match result with | Some _ -> result @@ -210,10 +210,10 @@ module internal FSharpEnvironment = None - // Apply the given function to the registry entry corresponding to the subkey. + // Apply the given function to the registry entry corresponding to the subKey. // The reg key is disposed at the end of the scope. - let useKey subkey f = - let key = Registry.LocalMachine.OpenSubKey subkey + let useKey subKey f = + let key = Registry.LocalMachine.OpenSubKey subKey try f key finally match key with @@ -221,12 +221,12 @@ module internal FSharpEnvironment = | _ -> key.Dispose() // Check if the framework version 4.5 or above is installed at the given key entry - let IsNetFx45OrAboveInstalledAt subkey = + let IsNetFx45OrAboveInstalledAt subKey = try - useKey subkey (fun regkey -> - match regkey with + useKey subKey (fun regKey -> + match regKey with | null -> false - | _ -> regkey.GetValue("Release", 0) :?> int |> (fun s -> s >= 0x50000)) // 0x50000 implies 4.5.0 + | _ -> regKey.GetValue("Release", 0) :?> int |> (fun s -> s >= 0x50000)) // 0x50000 implies 4.5.0 with _ -> false // Check if the framework version 4.5 or above is installed diff --git a/src/utils/HashMultiMap.fs b/src/utils/HashMultiMap.fs index 7f571c232d0..e3765ced86c 100644 --- a/src/utils/HashMultiMap.fs +++ b/src/utils/HashMultiMap.fs @@ -9,16 +9,16 @@ open Microsoft.FSharp.Collections // Each entry in the HashMultiMap dictionary has at least one entry. Under normal usage each entry has _only_ // one entry. So use two hash tables: one for the main entries and one for the overflow. [] -type internal HashMultiMap<'Key,'Value>(n: int, hasheq: IEqualityComparer<'Key>) = +type internal HashMultiMap<'Key,'Value>(n: int, hashEq: IEqualityComparer<'Key>) = - let firstEntries = Dictionary<_,_>(n,hasheq) + let firstEntries = Dictionary<_,_>(n,hashEq) - let rest = Dictionary<_,_>(3,hasheq) + let rest = Dictionary<_,_>(3,hashEq) - new (hasheq : IEqualityComparer<'Key>) = HashMultiMap<'Key,'Value>(11, hasheq) + new (hashEq : IEqualityComparer<'Key>) = HashMultiMap<'Key,'Value>(11, hashEq) - new (seq : seq<'Key * 'Value>, hasheq : IEqualityComparer<'Key>) as x = - new HashMultiMap<'Key,'Value>(11, hasheq) + new (seq : seq<'Key * 'Value>, hashEq : IEqualityComparer<'Key>) as x = + new HashMultiMap<'Key,'Value>(11, hashEq) then seq |> Seq.iter (fun (k,v) -> x.Add(k,v)) member x.GetRest(k) = diff --git a/src/utils/prim-lexing.fsi b/src/utils/prim-lexing.fsi index bf9eb3171c1..b0579d71e2f 100644 --- a/src/utils/prim-lexing.fsi +++ b/src/utils/prim-lexing.fsi @@ -32,7 +32,7 @@ module SourceText = // // NOTE: the code in this file is a drop-in replacement runtime for Lexing.fsi from the FsLexYacc repository // and is referenced by generated code for the three FsLex generated lexers in the F# compiler. -// The underlying table format intepreted must precisely match the format generated by FsLex. +// The underlying table format interpreted must precisely match the format generated by FsLex. namespace Internal.Utilities.Text.Lexing open System.Collections.Generic diff --git a/src/utils/prim-parsing.fs b/src/utils/prim-parsing.fs index 9ce01bff907..c247161e9c0 100644 --- a/src/utils/prim-parsing.fs +++ b/src/utils/prim-parsing.fs @@ -341,7 +341,7 @@ module internal Implementation = if errorSuppressionCountDown > 0 then errorSuppressionCountDown <- errorSuppressionCountDown - 1 #if DEBUG - if Flags.debug then Console.WriteLine("shifting, reduced errorRecoverylevel to {0}\n", errorSuppressionCountDown) + if Flags.debug then Console.WriteLine("shifting, reduced errorRecoveryLevel to {0}\n", errorSuppressionCountDown) #endif let nextState = actionValue action if not haveLookahead then failwith "shift on end of input!" From 2ce2c9e7fc9c49fc43fef51c9c07effb935908f6 Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Thu, 31 Oct 2019 03:10:18 +0300 Subject: [PATCH 14/68] Fix member declaration ranges (#7676) * Fix member declaration ranges * Fix member declaration ranges * Update baseline * Update baseline --- src/fsharp/pars.fsy | 113 +++++++------ tests/fsharp/typecheck/sigs/neg10.bsl | 8 +- tests/fsharp/typecheck/sigs/neg62.bsl | 8 +- tests/fsharp/typecheck/sigs/neg91.bsl | 2 +- .../EnumTypes/E_NoMethodsOnEnums01.fs | 2 +- .../basic/E_CantExtendTypeAbrev.fs | 2 +- .../WithOOP/E_NoInstanceOnMeasure01.fs | 2 +- tests/service/Common.fs | 8 +- tests/service/ServiceUntypedParseTests.fs | 158 +++++++++++++++--- tests/service/StructureTests.fs | 8 +- 10 files changed, 223 insertions(+), 88 deletions(-) diff --git a/src/fsharp/pars.fsy b/src/fsharp/pars.fsy index 64011e2c407..8a4988935c1 100644 --- a/src/fsharp/pars.fsy +++ b/src/fsharp/pars.fsy @@ -1623,21 +1623,23 @@ classDefnMemberGetSetElement: /* The core of a member definition */ memberCore: /* Methods and simple getter properties */ - | opt_inline bindingPattern opt_topReturnTypeWithTypeConstraints EQUALS typedSeqExprBlock - { let mRhs = $5.Range - let mWhole = unionRanges (rhs2 parseState 3 4) mRhs - let optReturnType = $3 - let bindingBuilder,mBindLhs = $2 - (fun vis memFlagsBuilder attrs -> - [ SynMemberDefn.Member (bindingBuilder (vis,$1,false,mBindLhs,NoSequencePointAtInvisibleBinding,optReturnType,$5,mRhs,[],attrs,Some(memFlagsBuilder MemberKind.Member)),unionRanges mWhole mBindLhs) ]) } + | opt_inline bindingPattern opt_topReturnTypeWithTypeConstraints EQUALS typedSeqExprBlock + { let mRhs = $5.Range + let optReturnType = $3 + let bindingBuilder, mBindLhs = $2 + (fun vis memFlagsBuilder attrs rangeStart -> + let memberFlags = Some (memFlagsBuilder MemberKind.Member) + let binding = bindingBuilder (vis, $1, false, mBindLhs, NoSequencePointAtInvisibleBinding, optReturnType, $5, mRhs, [], attrs, memberFlags) + let memberRange = unionRanges rangeStart mRhs + [ SynMemberDefn.Member (binding, memberRange) ]) } /* Properties with explicit get/set, also indexer properties */ - | opt_inline bindingPattern opt_topReturnTypeWithTypeConstraints classDefnMemberGetSet + | opt_inline bindingPattern opt_topReturnTypeWithTypeConstraints classDefnMemberGetSet { let mWhole = (rhs parseState 2, $4) ||> unionRangeWithListBy (fun (_,_,_,_,_,m2) -> m2) - let propertyNameBindingBuilder,_ = $2 + let propertyNameBindingBuilder, _ = $2 let optPropertyType = $3 let isMutable = false - (fun visNoLongerUsed memFlagsBuilder attrs -> + (fun visNoLongerUsed memFlagsBuilder attrs rangeStart -> let hasGet = ref false let hasSet = ref false @@ -1665,21 +1667,21 @@ memberCore: | SynPat.Attrib (p,_,_) -> go p | _ -> raiseParseErrorAt mBindLhs (FSComp.SR.parsInvalidDeclarationSyntax()) go pv - if getset = "get" then ( + if getset = "get" then if !hasGet then reportParseErrorAt mBindLhs (FSComp.SR.parsGetAndOrSetRequired()) None else hasGet := true Some MemberKind.PropertyGet - ) else if getset = "set" then ( + else if getset = "set" then if !hasSet then reportParseErrorAt mBindLhs (FSComp.SR.parsGetAndOrSetRequired()) None else hasSet := true Some MemberKind.PropertySet - ) else + else raiseParseErrorAt mBindLhs (FSComp.SR.parsGetAndOrSetRequired()) match memberKind with @@ -1697,7 +1699,7 @@ memberCore: let optReturnType = match (memberKind, optReturnType) with - | MemberKind.PropertySet,_ -> optReturnType + | MemberKind.PropertySet, _ -> optReturnType | _, None -> optPropertyType | _ -> optReturnType @@ -1719,35 +1721,39 @@ memberCore: | _ -> SynInfo.unnamedTopArg match memberKind, valSynInfo, memFlags.IsInstance with - | MemberKind.PropertyGet,SynValInfo ([],_ret), false - | MemberKind.PropertyGet,SynValInfo ([_],_ret), true -> + | MemberKind.PropertyGet, SynValInfo ([], _ret), false + | MemberKind.PropertyGet, SynValInfo ([_], _ret), true -> raiseParseErrorAt mBindLhs (FSComp.SR.parsGetterMustHaveAtLeastOneArgument()) - | MemberKind.PropertyGet,SynValInfo (thisArg :: indexOrUnitArgs :: rest,ret), true -> - if not rest.IsEmpty then reportParseErrorAt mBindLhs (FSComp.SR.parsGetterAtMostOneArgument()) - SynValInfo ([thisArg; indexOrUnitArgs],ret) + | MemberKind.PropertyGet, SynValInfo (thisArg :: indexOrUnitArgs :: rest, ret), true -> + if not rest.IsEmpty then + reportParseErrorAt mBindLhs (FSComp.SR.parsGetterAtMostOneArgument ()) + SynValInfo ([thisArg; indexOrUnitArgs], ret) - | MemberKind.PropertyGet,SynValInfo (indexOrUnitArgs :: rest,ret), false -> - if not rest.IsEmpty then reportParseErrorAt mBindLhs (FSComp.SR.parsGetterAtMostOneArgument()) - SynValInfo ([indexOrUnitArgs],ret) + | MemberKind.PropertyGet, SynValInfo (indexOrUnitArgs :: rest,ret), false -> + if not rest.IsEmpty then + reportParseErrorAt mBindLhs (FSComp.SR.parsGetterAtMostOneArgument ()) + SynValInfo ([indexOrUnitArgs], ret) - | MemberKind.PropertySet,SynValInfo ([thisArg;valueArg],ret), true -> - SynValInfo ([thisArg; adjustValueArg valueArg],ret) + | MemberKind.PropertySet, SynValInfo ([thisArg;valueArg], ret), true -> + SynValInfo ([thisArg; adjustValueArg valueArg], ret) - | MemberKind.PropertySet,SynValInfo (thisArg :: indexArgs :: valueArg :: rest,ret), true -> - if not rest.IsEmpty then reportParseErrorAt mBindLhs (FSComp.SR.parsSetterAtMostTwoArguments()) - SynValInfo ([thisArg; indexArgs @ adjustValueArg valueArg],ret) + | MemberKind.PropertySet, SynValInfo (thisArg :: indexArgs :: valueArg :: rest, ret), true -> + if not rest.IsEmpty then + reportParseErrorAt mBindLhs (FSComp.SR.parsSetterAtMostTwoArguments ()) + SynValInfo ([thisArg; indexArgs @ adjustValueArg valueArg], ret) - | MemberKind.PropertySet,SynValInfo ([valueArg],ret), false -> - SynValInfo ([adjustValueArg valueArg],ret) + | MemberKind.PropertySet, SynValInfo ([valueArg], ret), false -> + SynValInfo ([adjustValueArg valueArg], ret) - | MemberKind.PropertySet,SynValInfo (indexArgs :: valueArg :: rest,ret), _ -> - if not rest.IsEmpty then reportParseErrorAt mBindLhs (FSComp.SR.parsSetterAtMostTwoArguments()) - SynValInfo ([indexArgs @ adjustValueArg valueArg],ret) + | MemberKind.PropertySet, SynValInfo (indexArgs :: valueArg :: rest,ret), _ -> + if not rest.IsEmpty then + reportParseErrorAt mBindLhs (FSComp.SR.parsSetterAtMostTwoArguments ()) + SynValInfo ([indexArgs @ adjustValueArg valueArg], ret) | _ -> // should be unreachable, cover just in case - raiseParseErrorAt mBindLhs (FSComp.SR.parsInvalidProperty()) + raiseParseErrorAt mBindLhs (FSComp.SR.parsInvalidProperty ()) let valSynData = SynValData(Some(memFlags), valSynInfo,None) @@ -1808,7 +1814,9 @@ memberCore: go pv,PreXmlDoc.Merge doc2 doc - Some <| SynMemberDefn.Member (Binding (vis, NormalBinding, isInline, isMutable, attrs, xmlDocAdjusted, valSynData, bindingPatAdjusted, rhsRetInfo, rhsExpr, mBindLhs, spBind),mWhole))) + let binding = Binding (vis, NormalBinding, isInline, isMutable, attrs, xmlDocAdjusted, valSynData, bindingPatAdjusted, rhsRetInfo, rhsExpr, mBindLhs, spBind) + let memberRange = unionRanges rangeStart mWhole + Some (SynMemberDefn.Member (binding, memberRange)))) } @@ -1827,10 +1835,12 @@ classDefnMember: { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) [mkClassMemberLocalBindings(true,Some (rhs parseState 3),$1,$2,$4)] } - | opt_attributes opt_declVisibility memberFlags memberCore opt_ODECLEND - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) - let _,flags = $3 - $4 $2 flags $1 } + | opt_attributes opt_declVisibility memberFlags memberCore opt_ODECLEND + { let rangeStart = rhs parseState 1 + if Option.isSome $2 then + errorR (Error (FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier (), rhs parseState 2)) + let _, flags = $3 + $4 $2 flags $1 rangeStart } | opt_attributes opt_declVisibility interfaceMember appType opt_interfaceImplDefn { if not (isNil $1) then errorR(Error(FSComp.SR.parsAttributesAreNotPermittedOnInterfaceImplementations(),rhs parseState 1)) @@ -1869,9 +1879,11 @@ classDefnMember: $4 (Some (rhs parseState 3)) $1 true } | opt_attributes opt_declVisibility memberFlags autoPropsDefnDecl opt_ODECLEND - { if Option.isSome $2 then errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) - let isStatic, flags = $3 - $4 $1 isStatic flags } + { let rangeStart = rhs parseState 1 + if Option.isSome $2 then + errorR(Error(FSComp.SR.parsVisibilityDeclarationsShouldComePriorToIdentifier(),rhs parseState 2)) + let isStatic, flags = $3 + $4 $1 isStatic flags rangeStart } | opt_attributes opt_declVisibility NEW atomicPattern optAsSpec EQUALS typedSeqExprBlock opt_ODECLEND { let m = unionRanges (rhs2 parseState 3 6) $7.Range @@ -1903,12 +1915,13 @@ valDefnDecl: /* An auto-property definition in an object type definition */ autoPropsDefnDecl: | VAL opt_mutable opt_access ident opt_typ EQUALS typedSeqExprBlock classMemberSpfnGetSet - { let doc = grabXmlDoc(parseState,5) - let mValDecl = unionRanges (rhs parseState 1) $7.Range - let mGetSetOpt, getSet = $8 - if $2 then errorR(Error(FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet(),rhs parseState 3)) - (fun attribs isStatic flags -> - [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, flags, doc, $3, $7, mGetSetOpt, mValDecl) ]) } + { let doc = grabXmlDoc(parseState, 5) + let mGetSetOpt, getSet = $8 + if $2 then + errorR (Error (FSComp.SR.parsMutableOnAutoPropertyShouldBeGetSet (), rhs parseState 3)) + (fun attribs isStatic flags rangeStart -> + let memberRange = unionRanges rangeStart $7.Range + [ SynMemberDefn.AutoProperty(attribs, isStatic, $4, $5, getSet, flags, doc, $3, $7, mGetSetOpt, memberRange) ]) } /* An optional type on an auto-property definition */ @@ -2022,10 +2035,12 @@ objectImplementationMembers: /* One member in an object expression or interface implementation */ objectImplementationMember: | opt_attributes memberOrOverride memberCore opt_ODECLEND - { $3 None OverrideMemberFlags $1 } + { let rangeStart = rhs parseState 1 + $3 None OverrideMemberFlags $1 rangeStart } | opt_attributes memberOrOverride autoPropsDefnDecl opt_ODECLEND - { $3 $1 false OverrideMemberFlags } + { let rangeStart = rhs parseState 1 + $3 $1 false OverrideMemberFlags rangeStart } | opt_attributes memberOrOverride error { [] } diff --git a/tests/fsharp/typecheck/sigs/neg10.bsl b/tests/fsharp/typecheck/sigs/neg10.bsl index 64088e1e9e8..c31220273da 100644 --- a/tests/fsharp/typecheck/sigs/neg10.bsl +++ b/tests/fsharp/typecheck/sigs/neg10.bsl @@ -35,9 +35,9 @@ neg10.fs(54,17,54,20): typecheck error FS0060: Override implementations in augme neg10.fs(66,19,66,21): typecheck error FS0069: Interface implementations in augmentations are now deprecated. Interface implementations should be given on the initial declaration of a type. -neg10.fs(77,27,77,34): typecheck error FS0896: Enumerations cannot have members +neg10.fs(77,13,77,34): typecheck error FS0896: Enumerations cannot have members -neg10.fs(84,20,84,29): typecheck error FS0896: Enumerations cannot have members +neg10.fs(84,13,84,29): typecheck error FS0896: Enumerations cannot have members neg10.fs(90,23,90,41): typecheck error FS0907: Enumerations cannot have interface declarations @@ -45,11 +45,11 @@ neg10.fs(99,23,99,29): typecheck error FS0907: Enumerations cannot have interfac neg10.fs(107,10,107,17): typecheck error FS0964: Type abbreviations cannot have augmentations -neg10.fs(109,27,109,34): typecheck error FS0895: Type abbreviations cannot have members +neg10.fs(109,13,109,34): typecheck error FS0895: Type abbreviations cannot have members neg10.fs(114,10,114,17): typecheck error FS0964: Type abbreviations cannot have augmentations -neg10.fs(116,20,116,29): typecheck error FS0895: Type abbreviations cannot have members +neg10.fs(116,13,116,29): typecheck error FS0895: Type abbreviations cannot have members neg10.fs(120,10,120,17): typecheck error FS0964: Type abbreviations cannot have augmentations diff --git a/tests/fsharp/typecheck/sigs/neg62.bsl b/tests/fsharp/typecheck/sigs/neg62.bsl index d2bbd52d880..de4ae9d68ac 100644 --- a/tests/fsharp/typecheck/sigs/neg62.bsl +++ b/tests/fsharp/typecheck/sigs/neg62.bsl @@ -15,15 +15,15 @@ neg62.fs(22,5,22,14): typecheck error FS0960: 'let' and 'do' bindings must come neg62.fs(28,5,28,18): typecheck error FS0960: 'let' and 'do' bindings must come before member and interface definitions in type definitions -neg62.fs(31,19,31,32): typecheck error FS3133: 'member val' definitions are only permitted in types with a primary constructor. Consider adding arguments to your type definition, e.g. 'type X(args) = ...'. +neg62.fs(31,5,31,32): typecheck error FS3133: 'member val' definitions are only permitted in types with a primary constructor. Consider adding arguments to your type definition, e.g. 'type X(args) = ...'. -neg62.fs(31,19,31,32): typecheck error FS0902: Static value definitions may only be used in types with a primary constructor. Consider adding arguments to the type definition, e.g. 'type X(args) = ...'. +neg62.fs(31,5,31,32): typecheck error FS0902: Static value definitions may only be used in types with a primary constructor. Consider adding arguments to the type definition, e.g. 'type X(args) = ...'. -neg62.fs(34,12,34,25): typecheck error FS3133: 'member val' definitions are only permitted in types with a primary constructor. Consider adding arguments to your type definition, e.g. 'type X(args) = ...'. +neg62.fs(34,5,34,25): typecheck error FS3133: 'member val' definitions are only permitted in types with a primary constructor. Consider adding arguments to your type definition, e.g. 'type X(args) = ...'. neg62.fs(49,6,49,26): typecheck error FS0081: Implicit object constructors for structs must take at least one argument -neg62.fs(50,12,50,21): typecheck error FS0901: Structs cannot contain value definitions because the default constructor for structs will not execute these bindings. Consider adding additional arguments to the primary constructor for the type. +neg62.fs(50,5,50,21): typecheck error FS0901: Structs cannot contain value definitions because the default constructor for structs will not execute these bindings. Consider adding additional arguments to the primary constructor for the type. neg62.fs(54,26,54,34): typecheck error FS3135: To indicate that this property can be set, use 'member val PropertyName = expr with get,set'. diff --git a/tests/fsharp/typecheck/sigs/neg91.bsl b/tests/fsharp/typecheck/sigs/neg91.bsl index 7021297a7f1..559a4871f92 100644 --- a/tests/fsharp/typecheck/sigs/neg91.bsl +++ b/tests/fsharp/typecheck/sigs/neg91.bsl @@ -1,5 +1,5 @@ -neg91.fs(7,16,7,30): typecheck error FS0896: Enumerations cannot have members +neg91.fs(7,9,7,30): typecheck error FS0896: Enumerations cannot have members neg91.fs(10,10,10,15): typecheck error FS0956: Members that extend interface, delegate or enum types must be placed in a module separate to the definition of the type. This module must either have the AutoOpen attribute or be opened explicitly by client code to bring the extension members into scope. diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/EnumTypes/E_NoMethodsOnEnums01.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/EnumTypes/E_NoMethodsOnEnums01.fs index 4458338c770..b4e05661698 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/EnumTypes/E_NoMethodsOnEnums01.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/EnumTypes/E_NoMethodsOnEnums01.fs @@ -1,5 +1,5 @@ // #Regression #Conformance #ObjectOrientedTypes #Enums -//Enumerations cannot have members$ +//Enumerations cannot have members$ //The type 'Season' does not support the operator 'get_One'$ type Season = Spring=0 | Summer=1 | Autumn=2 | Winter=3 diff --git a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/E_CantExtendTypeAbrev.fs b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/E_CantExtendTypeAbrev.fs index beeac13d7e4..2883306a70a 100644 --- a/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/E_CantExtendTypeAbrev.fs +++ b/tests/fsharpqa/Source/Conformance/ObjectOrientedTypeDefinitions/TypeExtensions/basic/E_CantExtendTypeAbrev.fs @@ -1,7 +1,7 @@ // #Regression #Conformance #ObjectOrientedTypes #TypeExtensions // Verify you can't add type extensions to a type abbreviation //Type abbreviations cannot have augmentations$ -//Type abbreviations cannot have members$ +//Type abbreviations cannot have members$ type string with member this.ReturnFive() = 5 diff --git a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_NoInstanceOnMeasure01.fs b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_NoInstanceOnMeasure01.fs index e80950ee9e4..4ff94cf8683 100644 --- a/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_NoInstanceOnMeasure01.fs +++ b/tests/fsharpqa/Source/Conformance/UnitsOfMeasure/WithOOP/E_NoInstanceOnMeasure01.fs @@ -2,7 +2,7 @@ // Test error when adding instance methods to Measure types. -//Measure declarations may have only static members$ +//Measure declarations may have only static members$ [] type kg = diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 6920e682afe..946995e4c17 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -190,7 +190,6 @@ let parseAndCheckScript (file, input) = let parseSourceCode (name: string, code: string) = let location = Path.Combine(Path.GetTempPath(),"test"+string(hash (name, code))) try Directory.CreateDirectory(location) |> ignore with _ -> () - let projPath = Path.Combine(location, name + ".fsproj") let filePath = Path.Combine(location, name + ".fs") let dllPath = Path.Combine(location, name + ".dll") let args = mkProjectCommandLineArgs(dllPath, [filePath]) @@ -198,6 +197,13 @@ let parseSourceCode (name: string, code: string) = let parseResults = checker.ParseFile(filePath, FSharp.Compiler.Text.SourceText.ofString code, options) |> Async.RunSynchronously parseResults.ParseTree +open FSharp.Compiler.Ast + +let parseSourceCodeAndGetModule (source: string) = + match parseSourceCode ("test", source) with + | Some (ParsedInput.ImplFile (ParsedImplFileInput (_, _, _, _, _, [ moduleOrNamespace ], _))) -> moduleOrNamespace + | _ -> failwith "Could not get module decls" + /// Extract range info let tups (m:Range.range) = (m.StartLine, m.StartColumn), (m.EndLine, m.EndColumn) diff --git a/tests/service/ServiceUntypedParseTests.fs b/tests/service/ServiceUntypedParseTests.fs index ac4e1565617..ecf91ee4cab 100644 --- a/tests/service/ServiceUntypedParseTests.fs +++ b/tests/service/ServiceUntypedParseTests.fs @@ -127,25 +127,139 @@ let foo6 = () [<>] let foo7 = () """ - match parseSourceCode ("test", source) with - | Some (ParsedInput.ImplFile (ParsedImplFileInput (_,_,_,_,_,[SynModuleOrNamespace (_,_,_,decls,_,_,_,_)],_))) -> - decls |> List.map (fun decl -> - match decl with - | SynModuleDecl.Let (_,[Binding(_,_,_,_,attributeLists,_,_,_,_,_,_,_)],_) -> - attributeLists |> List.map (fun list -> - let r = list.Range - - list.Attributes.Length, - ((r.StartLine, r.StartColumn), (r.EndLine, r.EndColumn))) - - | _ -> failwith "Could not get binding") - |> shouldEqual - [ [ (1, ((2, 0), (2, 5))) ] - [ (1, ((5, 0), (5, 5))); (2, ((6, 0), (6, 7))) ] - [ (1, ((9, 0), (9, 5))); (2, ((9, 6), (9, 13))) ] - [ (1, ((12, 0), (13, 0))) ] - [ (1, ((15, 0), (15, 4))) ] - [ (0, ((18, 0), (18, 2))) ] - [ (0, ((21, 0), (21, 4))) ] ] - - | _ -> failwith "Could not get module decls" + let (SynModuleOrNamespace (_, _, _, decls, _, _, _, _)) = parseSourceCodeAndGetModule source + decls |> List.map (fun decl -> + match decl with + | SynModuleDecl.Let (_,[Binding(_,_,_,_,attributeLists,_,_,_,_,_,_,_)],_) -> + attributeLists |> List.map (fun list -> + let r = list.Range + + list.Attributes.Length, + ((r.StartLine, r.StartColumn), (r.EndLine, r.EndColumn))) + + | _ -> failwith "Could not get binding") + |> shouldEqual + [ [ (1, ((2, 0), (2, 5))) ] + [ (1, ((5, 0), (5, 5))); (2, ((6, 0), (6, 7))) ] + [ (1, ((9, 0), (9, 5))); (2, ((9, 6), (9, 13))) ] + [ (1, ((12, 0), (13, 0))) ] + [ (1, ((15, 0), (15, 4))) ] + [ (0, ((18, 0), (18, 2))) ] + [ (0, ((21, 0), (21, 4))) ] ] + + +module TypeMemberRanges = + + let getTypeMemberRange source = + let (SynModuleOrNamespace (_, _, _, decls, _, _, _, _)) = parseSourceCodeAndGetModule source + match decls with + | [ SynModuleDecl.Types ([ TypeDefn (_, SynTypeDefnRepr.ObjectModel (_, memberDecls, _), _, _) ], _) ] -> + memberDecls |> List.map (fun memberDecl -> + let range = memberDecl.Range + (range.StartLine, range.StartColumn), (range.EndLine, range.EndColumn)) + + | _ -> failwith "Could not get member" + + + [] + let ``Member range 01 - Simple``() = + let source = """ +type T = + member x.Foo() = () +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 23) ] + + + [] + let ``Member range 02 - Static``() = + let source = """ +type T = + static member Foo() = () +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 28) ] + + + [] + let ``Member range 03 - Attribute``() = + let source = """ +type T = + [] + static member Foo() = () +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (4, 28) ] + + + [] + let ``Member range 04 - Property``() = + let source = """ +type T = + member x.P = () +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) ] + + + [] + let ``Member range 05 - Setter only property``() = + let source = """ +type T = + member x.P with set (value) = v <- value +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 44) ] + + + [] + let ``Member range 06 - Read-write property``() = + let source = """ +type T = + member this.MyReadWriteProperty + with get () = x + and set (value) = x <- value +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (5, 36) + (3, 4), (5, 36) ] + + + [] + let ``Member range 07 - Auto property``() = + let source = """ +type T = + member val Property1 = "" +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] + + + [] + let ``Member range 08 - Auto property with setter``() = + let source = """ +type T = + member val Property1 = "" with get, set +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 29) ] + + + [] + let ``Member range 09 - Abstract slot``() = + let source = """ +type T = + abstract P: int + abstract M: unit -> unit +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 19) + (4, 4), (4, 28) ] + + [] + let ``Member range 10 - Val field``() = + let source = """ +type T = + val x: int +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 14) ] + + + [] + let ``Member range 11 - Ctor``() = + let source = """ +type T = + new (x:int) = () +""" + getTypeMemberRange source |> shouldEqual [ (3, 4), (3, 20) ] diff --git a/tests/service/StructureTests.fs b/tests/service/StructureTests.fs index e3f7b7fe9b2..c3583fe5ab1 100644 --- a/tests/service/StructureTests.fs +++ b/tests/service/StructureTests.fs @@ -106,7 +106,7 @@ type Color = => [ (2, 5, 9, 55), (2, 11, 9, 55) (3, 4, 5, 10), (3, 4, 5, 10) (7, 4, 9, 55), (7, 25, 9, 55) - (8, 15, 9, 55), (8, 27, 9, 55) + (8, 8, 9, 55), (8, 27, 9, 55) (8, 15, 9, 55), (8, 27, 9, 55) ] [] @@ -127,7 +127,7 @@ type Color = (3, 4, 4, 14), (3, 4, 4, 14) (3, 6, 4, 13), (3, 6, 4, 13) (8, 4, 10, 55), (8, 25, 10, 55) - (9, 15, 10, 55), (9, 27, 10, 55) + (9, 8, 10, 55), (9, 27, 10, 55) (9, 15, 10, 55), (9, 27, 10, 55) ] [] @@ -181,13 +181,13 @@ module MyModule = // 2 (7, 9, 15, 59), (7, 15, 15, 59) (8, 8, 11, 9), (8, 8, 11, 9) (13, 8, 15, 59), (13, 29, 15, 59) - (14, 19, 15, 59), (14, 31, 15, 59) + (14, 12, 15, 59), (14, 31, 15, 59) (14, 19, 15, 59), (14, 31, 15, 59) (17, 4, 27, 63), (17, 24, 27, 63) (19, 13, 27, 63), (19, 25, 27, 63) (20, 12, 23, 13), (20, 12, 23, 13) (25, 12, 27, 63), (25, 33, 27, 63) - (26, 23, 27, 63), (26, 35, 27, 63) + (26, 16, 27, 63), (26, 35, 27, 63) (26, 23, 27, 63), (26, 35, 27, 63) ] From 95d8f1b6c11ec88273f6d3074059dd9727a6ae7b Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 17:25:34 -0700 Subject: [PATCH 15/68] Cleanup, tests pass --- src/fsharp/IlxGen.fs | 81 +- src/fsharp/Optimizer.fs | 9 - .../fsharp/Compiler/Stress/LargeExprTests.fs | 899 ++++++++++++++++++ 3 files changed, 934 insertions(+), 55 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 4eed15abc50..b6e0926233e 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2663,19 +2663,23 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. // Since code is branching and joining, the cgbuf stack is maintained manually. let targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches - let rec processTarget (targetQueue: Queue<_>) = + + let rec popTargetQueue () = if targetQueue.Count > 0 then - let f = targetQueue.Dequeue() + let f = targetQueue.Dequeue () let genTargetInfoOpt = f () match genTargetInfoOpt with - | Some(eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> - GenExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget - | _ -> - () - processTarget targetQueue - processTarget targetQueue - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - contf Fake + | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> + popTargetQueue () + ) + | _ -> + popTargetQueue () + else + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + contf Fake + + popTargetQueue () | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> if canProcessSequencePoint then @@ -4879,9 +4883,9 @@ and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeat let rec genRemaining remaining (queue: Queue<_>) = match remaining with | [] -> None - | (KeyValue(targetIdx, (targetInfo, _))) :: rest -> + | (KeyValue(_, (targetInfo, _))) :: rest -> queue.Enqueue(fun () -> genRemaining rest queue) - Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) + Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel) genRemaining remaining queue @@ -4927,12 +4931,11 @@ and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree CG.SetMarkToHere cgbuf endScope GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv rest targets repeatSP targetInfos sequel - | TDSuccess (_es, _targetIdx) -> - [(inplabOpt, eenv, tree)] - //GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel + | TDSuccess _ -> + [(inplabOpt, eenv, tree)] | TDSwitch(e, cases, dflt, m) -> - GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases dflt m targets repeatSP targetInfos sequel + GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases dflt m targets repeatSP sequel and GetTarget (targets:_[]) n = if n >= targets.Length then failwith "GetTarget: target not found in decision tree" @@ -4975,7 +4978,7 @@ and GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx // In debug mode push all decision tree targets to after the switching let isTargetPostponed, genTargetInfoOpt = if cenv.opts.localOptimizationsAreOn then - false, Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel) + false, Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel) else CG.EmitInstr cgbuf (pop 0) Push0 (I_br targetMarkBeforeBinds.CodeLabel) true, None @@ -4983,13 +4986,7 @@ and GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx let targetInfos = IntMap.add targetIdx (targetInfo, isTargetPostponed) targetInfos targetInfos, genTargetInfoOpt -//and GenPostponedDecisionTreeTargets cenv cgbuf stackAtTargets targetInfos sequel : unit = -// let targetInfos = targetInfos |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) -// for (KeyValue(targetIdx, (targetInfo, isTargetPostponed))) in targetInfos do -// if isTargetPostponed then -// GenDecisionTreeTarget cenv cgbuf stackAtTargets targetIdx targetInfo sequel - -and GenDecisionTreeTarget cenv cgbuf stackAtTargets _targetIdx (targetMarkBeforeBinds, targetMarkAfterBinds, eenvAtTarget, successExpr, spTarget, repeatSP, vs, binds, startScope, endScope) sequel = +and GenDecisionTreeTarget cenv cgbuf stackAtTargets (targetMarkBeforeBinds, targetMarkAfterBinds, eenvAtTarget, successExpr, spTarget, repeatSP, vs, binds, startScope, endScope) sequel = CG.SetMarkToHere cgbuf targetMarkBeforeBinds let spExpr = (match spTarget with SequencePointAtTarget -> SPAlways | SuppressSequencePointAtTarget _ -> SPSuppress) @@ -5011,10 +5008,8 @@ and GenDecisionTreeTarget cenv cgbuf stackAtTargets _targetIdx (targetMarkBefore CG.SetMarkToHere cgbuf targetMarkAfterBinds CG.SetStack cgbuf stackAtTargets (eenvAtTarget, spExpr, successExpr, (EndLocalScope(sequel, endScope))) - //GenExpr cenv cgbuf eenvAtTarget spExpr successExpr (EndLocalScope(sequel, endScope)) - -and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel = +and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP sequel = let g = cenv.g let m = e.Range match inplabOpt with None -> () | Some inplab -> CG.SetMarkToHere cgbuf inplab @@ -5024,7 +5019,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau // optimize a test against a boolean value, i.e. the all-important if-then-else | TCase(DecisionTreeTest.Const(Const.Bool b), successTree) :: _ -> let failureTree = (match defaultTargetOpt with None -> cases.Tail.Head.CaseTree | Some d -> d) - GenDecisionTreeTest cenv eenv.cloc cgbuf stackAtTargets e None eenv (if b then successTree else failureTree) (if b then failureTree else successTree) targets repeatSP targetInfos sequel + GenDecisionTreeTest cenv eenv.cloc cgbuf e None eenv (if b then successTree else failureTree) (if b then failureTree else successTree) targets sequel // // Remove a single test for a union case . Union case tests are always exa //| [ TCase(DecisionTreeTest.UnionCase _, successTree) ] when (defaultTargetOpt.IsNone) -> @@ -5041,7 +5036,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau let cuspec = GenUnionSpec cenv.amap m eenv.tyenv c.TyconRef tyargs let idx = c.Index let avoidHelpers = entityRefInThisAssembly g.compilingFslib c.TyconRef - GenDecisionTreeTest cenv eenv.cloc cgbuf stackAtTargets e (Some (pop 1, Push [g.ilg.typ_Bool], Choice1Of2 (avoidHelpers, cuspec, idx))) eenv successTree failureTree targets repeatSP targetInfos sequel + GenDecisionTreeTest cenv eenv.cloc cgbuf e (Some (pop 1, Push [g.ilg.typ_Bool], Choice1Of2 (avoidHelpers, cuspec, idx))) eenv successTree failureTree targets sequel | _ -> let caseLabels = List.map (fun _ -> CG.GenerateDelayMark cgbuf "switch_case") cases @@ -5072,7 +5067,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau BI_brtrue | _ -> failwith "internal error: GenDecisionTreeSwitch" CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (bi, (List.head caseLabels).CodeLabel)) - GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel + GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases | DecisionTreeTest.ActivePatternCase _ -> error(InternalError("internal error in codegen: DecisionTreeTest.ActivePatternCase", switchm)) | DecisionTreeTest.UnionCase (hdc, tyargs) -> @@ -5088,7 +5083,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau let avoidHelpers = entityRefInThisAssembly g.compilingFslib hdc.TyconRef EraseUnions.emitDataSwitch g.ilg (UnionCodeGen cgbuf) (avoidHelpers, cuspec, dests) CG.EmitInstrs cgbuf (pop 1) Push0 [ ] // push/pop to match the line above - GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel + GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases | DecisionTreeTest.Const c -> GenExpr cenv cgbuf eenv SPSuppress e Continue @@ -5131,25 +5126,24 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau CG.EmitInstr cgbuf (pop 1) Push0 (I_switch destinationLabels) else error(InternalError("non-dense integer matches not implemented in codegen - these should have been removed by the pattern match compiler", switchm)) - GenDecisionTreeCases cenv cgbuf stackAtTargets eenv targets repeatSP targetInfos defaultTargetOpt caseLabels cases sequel + GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases | _ -> error(InternalError("these matches should never be needed", switchm)) -and GenDecisionTreeCases _cenv cgbuf stackAtTargets eenv _targets _repeatSP _targetInfos defaultTargetOpt caseLabels cases _sequel = +and GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases = assert(cgbuf.GetCurrentStack() = stackAtTargets) // cgbuf stack should be unchanged over tests. [bug://1750]. - let targetInfos = + let decisions = match defaultTargetOpt with - | Some defaultTarget -> [(None, eenv, defaultTarget)] //GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel + | Some defaultTarget -> [(None, eenv, defaultTarget)] | None -> [] - (targetInfos, caseLabels, cases) - |||> List.fold2 (fun targetInfos caseLabel (TCase(_, caseTree)) -> targetInfos @ [(Some caseLabel, eenv, caseTree)]) - //GenDecisionTreeAndTargetsInner cenv cgbuf (Some caseLabel) stackAtTargets eenv caseTree targets repeatSP targetInfos sequel) + (decisions, caseLabels, cases) + |||> List.fold2 (fun decisions caseLabel (TCase(_, caseTree)) -> decisions @ [(Some caseLabel, eenv, caseTree)]) // Used for the peephole optimization below and (|BoolExpr|_|) = function Expr.Const (Const.Bool b1, _, _) -> Some b1 | _ -> None -and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTree failureTree targets _repeatSP _targetInfos sequel = +and GenDecisionTreeTest cenv cloc cgbuf e tester eenv successTree failureTree targets sequel = let g = cenv.g match successTree, failureTree with @@ -5198,13 +5192,8 @@ and GenDecisionTreeTest cenv cloc cgbuf _stackAtTargets e tester eenv successTre | Choice2Of2 i -> CG.EmitInstr cgbuf pops pushes i CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (BI_brfalse, failure.CodeLabel)) - [ - (None, eenv, successTree) - (Some failure, eenv, failureTree) - ] - // let targetInfos = GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv successTree targets repeatSP targetInfos sequel - - // GenDecisionTreeAndTargetsInner cenv cgbuf (Some failure) stackAtTargets eenv failureTree targets repeatSP targetInfos sequel + [ (None, eenv, successTree) + (Some failure, eenv, failureTree) ] /// Generate fixups for letrec bindings and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFieldSpec, e2, _m) = diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 1fbc5338f49..8f55424368a 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -2921,15 +2921,6 @@ and OptimizeLambdas (vspec: Val option) cenv env topValInfo e ety = let env = Option.foldBack (BindInternalValToUnknown cenv) baseValOpt env let env = BindTypeVarsToUnknown tps env let env = List.foldBack (BindInternalValsToUnknown cenv) vsl env - - let cenv = - match env.functionVal with - // If the lambda is compiler generated and we are in the reporing phase, allow lambda to be split. - // As an example, allows generated GetHashCode/Equals/CompareTo/etc methods to be split even if optimizations were off. - // This helps prevent stack overflows in IlxGen.fs. - | Some (v, _) when v.IsCompilerGenerated && cenv.settings.reportingPhase -> SetAbstractBigTargetsOn cenv - | _ -> cenv - let env = BindInternalValsToUnknown cenv (Option.toList baseValOpt) env let bodyR, bodyinfo = OptimizeExpr cenv env body let exprR = mkMemberLambdas m tps ctorThisValOpt baseValOpt vsl (bodyR, bodyty) diff --git a/tests/fsharp/Compiler/Stress/LargeExprTests.fs b/tests/fsharp/Compiler/Stress/LargeExprTests.fs index 004f737cb9c..1773d1994d0 100644 --- a/tests/fsharp/Compiler/Stress/LargeExprTests.fs +++ b/tests/fsharp/Compiler/Stress/LargeExprTests.fs @@ -3038,6 +3038,905 @@ type TestRecord = test998: int test999: int test1000: int + test1101: int + test1102: int + test1103: int + test1104: int + test1105: int + test1106: int + test1107: int + test1108: int + test1109: int + test1110: int + test1111: int + test1112: int + test1113: int + test1114: int + test1115: int + test1116: int + test1117: int + test1118: int + test1119: int + test1120: int + test1121: int + test1122: int + test1123: int + test1124: int + test1125: int + test1126: int + test1127: int + test1128: int + test1129: int + test1130: int + test1131: int + test1132: int + test1133: int + test1134: int + test1135: int + test1136: int + test1137: int + test1138: int + test1139: int + test1140: int + test1141: int + test1142: int + test1143: int + test1144: int + test1145: int + test1146: int + test1147: int + test1148: int + test1149: int + test1150: int + test1151: int + test1152: int + test1153: int + test1154: int + test1155: int + test1156: int + test1157: int + test1158: int + test1159: int + test1160: int + test1161: int + test1162: int + test1163: int + test1164: int + test1165: int + test1166: int + test1167: int + test1168: int + test1169: int + test1170: int + test1171: int + test1172: int + test1173: int + test1174: int + test1175: int + test1176: int + test1177: int + test1178: int + test1179: int + test1180: int + test1181: int + test1182: int + test1183: int + test1184: int + test1185: int + test1186: int + test1187: int + test1188: int + test1189: int + test1190: int + test1191: int + test1192: int + test1193: int + test1194: int + test1195: int + test1196: int + test1197: int + test1198: int + test1199: int + test1200: int + test1201: int + test1202: int + test1203: int + test1204: int + test1205: int + test1206: int + test1207: int + test1208: int + test1209: int + test1210: int + test1211: int + test1212: int + test1213: int + test1214: int + test1215: int + test1216: int + test1217: int + test1218: int + test1219: int + test1220: int + test1221: int + test1222: int + test1223: int + test1224: int + test1225: int + test1226: int + test1227: int + test1228: int + test1229: int + test1230: int + test1231: int + test1232: int + test1233: int + test1234: int + test1235: int + test1236: int + test1237: int + test1238: int + test1239: int + test1240: int + test1241: int + test1242: int + test1243: int + test1244: int + test1245: int + test1246: int + test1247: int + test1248: int + test1249: int + test1250: int + test1251: int + test1252: int + test1253: int + test1254: int + test1255: int + test1256: int + test1257: int + test1258: int + test1259: int + test1260: int + test1261: int + test1262: int + test1263: int + test1264: int + test1265: int + test1266: int + test1267: int + test1268: int + test1269: int + test1270: int + test1271: int + test1272: int + test1273: int + test1274: int + test1275: int + test1276: int + test1277: int + test1278: int + test1279: int + test1280: int + test1281: int + test1282: int + test1283: int + test1284: int + test1285: int + test1286: int + test1287: int + test1288: int + test1289: int + test1290: int + test1291: int + test1292: int + test1293: int + test1294: int + test1295: int + test1296: int + test1297: int + test1298: int + test1299: int + test1300: int + test1301: int + test1302: int + test1303: int + test1304: int + test1305: int + test1306: int + test1307: int + test1308: int + test1309: int + test1310: int + test1311: int + test1312: int + test1313: int + test1314: int + test1315: int + test1316: int + test1317: int + test1318: int + test1319: int + test1320: int + test1321: int + test1322: int + test1323: int + test1324: int + test1325: int + test1326: int + test1327: int + test1328: int + test1329: int + test1330: int + test1331: int + test1332: int + test1333: int + test1334: int + test1335: int + test1336: int + test1337: int + test1338: int + test1339: int + test1340: int + test1341: int + test1342: int + test1343: int + test1344: int + test1345: int + test1346: int + test1347: int + test1348: int + test1349: int + test1350: int + test1351: int + test1352: int + test1353: int + test1354: int + test1355: int + test1356: int + test1357: int + test1358: int + test1359: int + test1360: int + test1361: int + test1362: int + test1363: int + test1364: int + test1365: int + test1366: int + test1367: int + test1368: int + test1369: int + test1370: int + test1371: int + test1372: int + test1373: int + test1374: int + test1375: int + test1376: int + test1377: int + test1378: int + test1379: int + test1380: int + test1381: int + test1382: int + test1383: int + test1384: int + test1385: int + test1386: int + test1387: int + test1388: int + test1389: int + test1390: int + test1391: int + test1392: int + test1393: int + test1394: int + test1395: int + test1396: int + test1397: int + test1398: int + test1399: int + test1400: int + test1401: int + test1402: int + test1403: int + test1404: int + test1405: int + test1406: int + test1407: int + test1408: int + test1409: int + test1410: int + test1411: int + test1412: int + test1413: int + test1414: int + test1415: int + test1416: int + test1417: int + test1418: int + test1419: int + test1420: int + test1421: int + test1422: int + test1423: int + test1424: int + test1425: int + test1426: int + test1427: int + test1428: int + test1429: int + test1430: int + test1431: int + test1432: int + test1433: int + test1434: int + test1435: int + test1436: int + test1437: int + test1438: int + test1439: int + test1440: int + test1441: int + test1442: int + test1443: int + test1444: int + test1445: int + test1446: int + test1447: int + test1448: int + test1449: int + test1450: int + test1451: int + test1452: int + test1453: int + test1454: int + test1455: int + test1456: int + test1457: int + test1458: int + test1459: int + test1460: int + test1461: int + test1462: int + test1463: int + test1464: int + test1465: int + test1466: int + test1467: int + test1468: int + test1469: int + test1470: int + test1471: int + test1472: int + test1473: int + test1474: int + test1475: int + test1476: int + test1477: int + test1478: int + test1479: int + test1480: int + test1481: int + test1482: int + test1483: int + test1484: int + test1485: int + test1486: int + test1487: int + test1488: int + test1489: int + test1490: int + test1491: int + test1492: int + test1493: int + test1494: int + test1495: int + test1496: int + test1497: int + test1498: int + test1499: int + test1500: int + test1501: int + test1502: int + test1503: int + test1504: int + test1505: int + test1506: int + test1507: int + test1508: int + test1509: int + test1510: int + test1511: int + test1512: int + test1513: int + test1514: int + test1515: int + test1516: int + test1517: int + test1518: int + test1519: int + test1520: int + test1521: int + test1522: int + test1523: int + test1524: int + test1525: int + test1526: int + test1527: int + test1528: int + test1529: int + test1530: int + test1531: int + test1532: int + test1533: int + test1534: int + test1535: int + test1536: int + test1537: int + test1538: int + test1539: int + test1540: int + test1541: int + test1542: int + test1543: int + test1544: int + test1545: int + test1546: int + test1547: int + test1548: int + test1549: int + test1550: int + test1551: int + test1552: int + test1553: int + test1554: int + test1555: int + test1556: int + test1557: int + test1558: int + test1559: int + test1560: int + test1561: int + test1562: int + test1563: int + test1564: int + test1565: int + test1566: int + test1567: int + test1568: int + test1569: int + test1570: int + test1571: int + test1572: int + test1573: int + test1574: int + test1575: int + test1576: int + test1577: int + test1578: int + test1579: int + test1580: int + test1581: int + test1582: int + test1583: int + test1584: int + test1585: int + test1586: int + test1587: int + test1588: int + test1589: int + test1590: int + test1591: int + test1592: int + test1593: int + test1594: int + test1595: int + test1596: int + test1597: int + test1598: int + test1599: int + test1600: int + test1601: int + test1602: int + test1603: int + test1604: int + test1605: int + test1606: int + test1607: int + test1608: int + test1609: int + test1610: int + test1611: int + test1612: int + test1613: int + test1614: int + test1615: int + test1616: int + test1617: int + test1618: int + test1619: int + test1620: int + test1621: int + test1622: int + test1623: int + test1624: int + test1625: int + test1626: int + test1627: int + test1628: int + test1629: int + test1630: int + test1631: int + test1632: int + test1633: int + test1634: int + test1635: int + test1636: int + test1637: int + test1638: int + test1639: int + test1640: int + test1641: int + test1642: int + test1643: int + test1644: int + test1645: int + test1646: int + test1647: int + test1648: int + test1649: int + test1650: int + test1651: int + test1652: int + test1653: int + test1654: int + test1655: int + test1656: int + test1657: int + test1658: int + test1659: int + test1660: int + test1661: int + test1662: int + test1663: int + test1664: int + test1665: int + test1666: int + test1667: int + test1668: int + test1669: int + test1670: int + test1671: int + test1672: int + test1673: int + test1674: int + test1675: int + test1676: int + test1677: int + test1678: int + test1679: int + test1680: int + test1681: int + test1682: int + test1683: int + test1684: int + test1685: int + test1686: int + test1687: int + test1688: int + test1689: int + test1690: int + test1691: int + test1692: int + test1693: int + test1694: int + test1695: int + test1696: int + test1697: int + test1698: int + test1699: int + test1700: int + test1701: int + test1702: int + test1703: int + test1704: int + test1705: int + test1706: int + test1707: int + test1708: int + test1709: int + test1710: int + test1711: int + test1712: int + test1713: int + test1714: int + test1715: int + test1716: int + test1717: int + test1718: int + test1719: int + test1720: int + test1721: int + test1722: int + test1723: int + test1724: int + test1725: int + test1726: int + test1727: int + test1728: int + test1729: int + test1730: int + test1731: int + test1732: int + test1733: int + test1734: int + test1735: int + test1736: int + test1737: int + test1738: int + test1739: int + test1740: int + test1741: int + test1742: int + test1743: int + test1744: int + test1745: int + test1746: int + test1747: int + test1748: int + test1749: int + test1750: int + test1751: int + test1752: int + test1753: int + test1754: int + test1755: int + test1756: int + test1757: int + test1758: int + test1759: int + test1760: int + test1761: int + test1762: int + test1763: int + test1764: int + test1765: int + test1766: int + test1767: int + test1768: int + test1769: int + test1770: int + test1771: int + test1772: int + test1773: int + test1774: int + test1775: int + test1776: int + test1777: int + test1778: int + test1779: int + test1780: int + test1781: int + test1782: int + test1783: int + test1784: int + test1785: int + test1786: int + test1787: int + test1788: int + test1789: int + test1790: int + test1791: int + test1792: int + test1793: int + test1794: int + test1795: int + test1796: int + test1797: int + test1798: int + test1799: int + test1800: int + test1801: int + test1802: int + test1803: int + test1804: int + test1805: int + test1806: int + test1807: int + test1808: int + test1809: int + test1810: int + test1811: int + test1812: int + test1813: int + test1814: int + test1815: int + test1816: int + test1817: int + test1818: int + test1819: int + test1820: int + test1821: int + test1822: int + test1823: int + test1824: int + test1825: int + test1826: int + test1827: int + test1828: int + test1829: int + test1830: int + test1831: int + test1832: int + test1833: int + test1834: int + test1835: int + test1836: int + test1837: int + test1838: int + test1839: int + test1840: int + test1841: int + test1842: int + test1843: int + test1844: int + test1845: int + test1846: int + test1847: int + test1848: int + test1849: int + test1850: int + test1851: int + test1852: int + test1853: int + test1854: int + test1855: int + test1856: int + test1857: int + test1858: int + test1859: int + test1860: int + test1861: int + test1862: int + test1863: int + test1864: int + test1865: int + test1866: int + test1867: int + test1868: int + test1869: int + test1870: int + test1871: int + test1872: int + test1873: int + test1874: int + test1875: int + test1876: int + test1877: int + test1878: int + test1879: int + test1880: int + test1881: int + test1882: int + test1883: int + test1884: int + test1885: int + test1886: int + test1887: int + test1888: int + test1889: int + test1890: int + test1891: int + test1892: int + test1893: int + test1894: int + test1895: int + test1896: int + test1897: int + test1898: int + test1899: int + test1900: int + test1901: int + test1902: int + test1903: int + test1904: int + test1905: int + test1906: int + test1907: int + test1908: int + test1909: int + test1910: int + test1911: int + test1912: int + test1913: int + test1914: int + test1915: int + test1916: int + test1917: int + test1918: int + test1919: int + test1920: int + test1921: int + test1922: int + test1923: int + test1924: int + test1925: int + test1926: int + test1927: int + test1928: int + test1929: int + test1930: int + test1931: int + test1932: int + test1933: int + test1934: int + test1935: int + test1936: int + test1937: int + test1938: int + test1939: int + test1940: int + test1941: int + test1942: int + test1943: int + test1944: int + test1945: int + test1946: int + test1947: int + test1948: int + test1949: int + test1950: int + test1951: int + test1952: int + test1953: int + test1954: int + test1955: int + test1956: int + test1957: int + test1958: int + test1959: int + test1960: int + test1961: int + test1962: int + test1963: int + test1964: int + test1965: int + test1966: int + test1967: int + test1968: int + test1969: int + test1970: int + test1971: int + test1972: int + test1973: int + test1974: int + test1975: int + test1976: int + test1977: int + test1978: int + test1979: int + test1980: int + test1981: int + test1982: int + test1983: int + test1984: int + test1985: int + test1986: int + test1987: int + test1988: int + test1989: int + test1990: int + test1991: int + test1992: int + test1993: int + test1994: int + test1995: int + test1996: int + test1997: int + test1998: int + test1999: int } [] From a1e04efd816d455dd113ff5110a147883328d160 Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 17:27:16 -0700 Subject: [PATCH 16/68] We do not need this anymore --- src/fsharp/Optimizer.fs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index 8f55424368a..f4c1a4c95a9 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -421,14 +421,6 @@ type IncrementalOptimizationEnv = override x.ToString() = "" -let SetAbstractBigTargetsOn cenv = - { cenv with - settings = - { cenv.settings with - abstractBigTargets = true - } - } - //------------------------------------------------------------------------- // IsPartialExprVal - is the expr fully known? //------------------------------------------------------------------------- From ee9a677f130ed78f5894c26c9c17eba1eec31e0f Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 17:29:02 -0700 Subject: [PATCH 17/68] Remove commented code --- src/fsharp/IlxGen.fs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index b6e0926233e..6d9dedc737b 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2222,8 +2222,6 @@ and GenExprAux (cenv: cenv) (cgbuf: CodeGenBuffer) eenv sp expr sequel = | Expr.Const (c, m, ty) -> GenConstant cenv cgbuf eenv (c, m, ty) sequel - //| Expr.Match (spBind, exprm, tree, targets, m, ty) -> - // GenMatch cenv cgbuf eenv (spBind, exprm, tree, targets, m, ty) sequel | Expr.LetRec (binds, body, m, _) -> GenLetRec cenv cgbuf eenv (binds, body, m) sequel | Expr.Lambda _ | Expr.TyLambda _ -> From 6230834b2180ef0a0c0ca821d97972c5362bf321 Mon Sep 17 00:00:00 2001 From: Phillip Carter Date: Wed, 30 Oct 2019 17:31:31 -0700 Subject: [PATCH 18/68] Use framework Queue (#7709) --- src/fsharp/FSharp.Core/mailbox.fs | 45 ++----------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/src/fsharp/FSharp.Core/mailbox.fs b/src/fsharp/FSharp.Core/mailbox.fs index b5c91fe49ee..b2bec129719 100644 --- a/src/fsharp/FSharp.Core/mailbox.fs +++ b/src/fsharp/FSharp.Core/mailbox.fs @@ -4,6 +4,7 @@ namespace Microsoft.FSharp.Control open System open System.Threading + open System.Collections.Generic open Microsoft.FSharp.Core open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators open Microsoft.FSharp.Control @@ -11,48 +12,6 @@ namespace Microsoft.FSharp.Control open Microsoft.FSharp.Control.AsyncPrimitives open Microsoft.FSharp.Collections - /// We use our own internal implementation of queues to avoid a dependency on System.dll - type Queue<'T>() = - - let mutable array = [| |] - let mutable head = 0 - let mutable size = 0 - let mutable tail = 0 - - let SetCapacity capacity = - let destinationArray = Array.zeroCreate capacity - if (size > 0) then - if (head < tail) then - Array.Copy(array, head, destinationArray, 0, size) - - else - Array.Copy(array, head, destinationArray, 0, array.Length - head) - Array.Copy(array, 0, destinationArray, array.Length - head, tail) - array <- destinationArray - head <- 0 - tail <- if (size = capacity) then 0 else size - - member x.Dequeue() = - if (size = 0) then - failwith "Dequeue" - let local = array.[head] - array.[head] <- Unchecked.defaultof<'T> - head <- (head + 1) % array.Length - size <- size - 1 - local - - member this.Enqueue item = - if (size = array.Length) then - let capacity = int ((int64 array.Length * 200L) / 100L) - let capacity = max capacity (array.Length + 4) - SetCapacity capacity - array.[tail] <- item - tail <- (tail + 1) % array.Length - size <- size + 1 - - member x.Count = size - - module AsyncHelpers = let awaitEither a1 a2 = @@ -93,7 +52,7 @@ namespace Microsoft.FSharp.Control [] type Mailbox<'Msg>(cancellationSupported: bool) = let mutable inboxStore = null - let mutable arrivals = new Queue<'Msg>() + let arrivals = Queue<'Msg>() let syncRoot = arrivals // Control elements indicating the state of the reader. When the reader is "blocked" at an From f166d6e485f19e2de189164e72f18f2a956d5f40 Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 18:30:49 -0700 Subject: [PATCH 19/68] Changed test so coreclr can pass --- .../fsharp/Compiler/Stress/LargeExprTests.fs | 899 ------------------ 1 file changed, 899 deletions(-) diff --git a/tests/fsharp/Compiler/Stress/LargeExprTests.fs b/tests/fsharp/Compiler/Stress/LargeExprTests.fs index 1773d1994d0..004f737cb9c 100644 --- a/tests/fsharp/Compiler/Stress/LargeExprTests.fs +++ b/tests/fsharp/Compiler/Stress/LargeExprTests.fs @@ -3038,905 +3038,6 @@ type TestRecord = test998: int test999: int test1000: int - test1101: int - test1102: int - test1103: int - test1104: int - test1105: int - test1106: int - test1107: int - test1108: int - test1109: int - test1110: int - test1111: int - test1112: int - test1113: int - test1114: int - test1115: int - test1116: int - test1117: int - test1118: int - test1119: int - test1120: int - test1121: int - test1122: int - test1123: int - test1124: int - test1125: int - test1126: int - test1127: int - test1128: int - test1129: int - test1130: int - test1131: int - test1132: int - test1133: int - test1134: int - test1135: int - test1136: int - test1137: int - test1138: int - test1139: int - test1140: int - test1141: int - test1142: int - test1143: int - test1144: int - test1145: int - test1146: int - test1147: int - test1148: int - test1149: int - test1150: int - test1151: int - test1152: int - test1153: int - test1154: int - test1155: int - test1156: int - test1157: int - test1158: int - test1159: int - test1160: int - test1161: int - test1162: int - test1163: int - test1164: int - test1165: int - test1166: int - test1167: int - test1168: int - test1169: int - test1170: int - test1171: int - test1172: int - test1173: int - test1174: int - test1175: int - test1176: int - test1177: int - test1178: int - test1179: int - test1180: int - test1181: int - test1182: int - test1183: int - test1184: int - test1185: int - test1186: int - test1187: int - test1188: int - test1189: int - test1190: int - test1191: int - test1192: int - test1193: int - test1194: int - test1195: int - test1196: int - test1197: int - test1198: int - test1199: int - test1200: int - test1201: int - test1202: int - test1203: int - test1204: int - test1205: int - test1206: int - test1207: int - test1208: int - test1209: int - test1210: int - test1211: int - test1212: int - test1213: int - test1214: int - test1215: int - test1216: int - test1217: int - test1218: int - test1219: int - test1220: int - test1221: int - test1222: int - test1223: int - test1224: int - test1225: int - test1226: int - test1227: int - test1228: int - test1229: int - test1230: int - test1231: int - test1232: int - test1233: int - test1234: int - test1235: int - test1236: int - test1237: int - test1238: int - test1239: int - test1240: int - test1241: int - test1242: int - test1243: int - test1244: int - test1245: int - test1246: int - test1247: int - test1248: int - test1249: int - test1250: int - test1251: int - test1252: int - test1253: int - test1254: int - test1255: int - test1256: int - test1257: int - test1258: int - test1259: int - test1260: int - test1261: int - test1262: int - test1263: int - test1264: int - test1265: int - test1266: int - test1267: int - test1268: int - test1269: int - test1270: int - test1271: int - test1272: int - test1273: int - test1274: int - test1275: int - test1276: int - test1277: int - test1278: int - test1279: int - test1280: int - test1281: int - test1282: int - test1283: int - test1284: int - test1285: int - test1286: int - test1287: int - test1288: int - test1289: int - test1290: int - test1291: int - test1292: int - test1293: int - test1294: int - test1295: int - test1296: int - test1297: int - test1298: int - test1299: int - test1300: int - test1301: int - test1302: int - test1303: int - test1304: int - test1305: int - test1306: int - test1307: int - test1308: int - test1309: int - test1310: int - test1311: int - test1312: int - test1313: int - test1314: int - test1315: int - test1316: int - test1317: int - test1318: int - test1319: int - test1320: int - test1321: int - test1322: int - test1323: int - test1324: int - test1325: int - test1326: int - test1327: int - test1328: int - test1329: int - test1330: int - test1331: int - test1332: int - test1333: int - test1334: int - test1335: int - test1336: int - test1337: int - test1338: int - test1339: int - test1340: int - test1341: int - test1342: int - test1343: int - test1344: int - test1345: int - test1346: int - test1347: int - test1348: int - test1349: int - test1350: int - test1351: int - test1352: int - test1353: int - test1354: int - test1355: int - test1356: int - test1357: int - test1358: int - test1359: int - test1360: int - test1361: int - test1362: int - test1363: int - test1364: int - test1365: int - test1366: int - test1367: int - test1368: int - test1369: int - test1370: int - test1371: int - test1372: int - test1373: int - test1374: int - test1375: int - test1376: int - test1377: int - test1378: int - test1379: int - test1380: int - test1381: int - test1382: int - test1383: int - test1384: int - test1385: int - test1386: int - test1387: int - test1388: int - test1389: int - test1390: int - test1391: int - test1392: int - test1393: int - test1394: int - test1395: int - test1396: int - test1397: int - test1398: int - test1399: int - test1400: int - test1401: int - test1402: int - test1403: int - test1404: int - test1405: int - test1406: int - test1407: int - test1408: int - test1409: int - test1410: int - test1411: int - test1412: int - test1413: int - test1414: int - test1415: int - test1416: int - test1417: int - test1418: int - test1419: int - test1420: int - test1421: int - test1422: int - test1423: int - test1424: int - test1425: int - test1426: int - test1427: int - test1428: int - test1429: int - test1430: int - test1431: int - test1432: int - test1433: int - test1434: int - test1435: int - test1436: int - test1437: int - test1438: int - test1439: int - test1440: int - test1441: int - test1442: int - test1443: int - test1444: int - test1445: int - test1446: int - test1447: int - test1448: int - test1449: int - test1450: int - test1451: int - test1452: int - test1453: int - test1454: int - test1455: int - test1456: int - test1457: int - test1458: int - test1459: int - test1460: int - test1461: int - test1462: int - test1463: int - test1464: int - test1465: int - test1466: int - test1467: int - test1468: int - test1469: int - test1470: int - test1471: int - test1472: int - test1473: int - test1474: int - test1475: int - test1476: int - test1477: int - test1478: int - test1479: int - test1480: int - test1481: int - test1482: int - test1483: int - test1484: int - test1485: int - test1486: int - test1487: int - test1488: int - test1489: int - test1490: int - test1491: int - test1492: int - test1493: int - test1494: int - test1495: int - test1496: int - test1497: int - test1498: int - test1499: int - test1500: int - test1501: int - test1502: int - test1503: int - test1504: int - test1505: int - test1506: int - test1507: int - test1508: int - test1509: int - test1510: int - test1511: int - test1512: int - test1513: int - test1514: int - test1515: int - test1516: int - test1517: int - test1518: int - test1519: int - test1520: int - test1521: int - test1522: int - test1523: int - test1524: int - test1525: int - test1526: int - test1527: int - test1528: int - test1529: int - test1530: int - test1531: int - test1532: int - test1533: int - test1534: int - test1535: int - test1536: int - test1537: int - test1538: int - test1539: int - test1540: int - test1541: int - test1542: int - test1543: int - test1544: int - test1545: int - test1546: int - test1547: int - test1548: int - test1549: int - test1550: int - test1551: int - test1552: int - test1553: int - test1554: int - test1555: int - test1556: int - test1557: int - test1558: int - test1559: int - test1560: int - test1561: int - test1562: int - test1563: int - test1564: int - test1565: int - test1566: int - test1567: int - test1568: int - test1569: int - test1570: int - test1571: int - test1572: int - test1573: int - test1574: int - test1575: int - test1576: int - test1577: int - test1578: int - test1579: int - test1580: int - test1581: int - test1582: int - test1583: int - test1584: int - test1585: int - test1586: int - test1587: int - test1588: int - test1589: int - test1590: int - test1591: int - test1592: int - test1593: int - test1594: int - test1595: int - test1596: int - test1597: int - test1598: int - test1599: int - test1600: int - test1601: int - test1602: int - test1603: int - test1604: int - test1605: int - test1606: int - test1607: int - test1608: int - test1609: int - test1610: int - test1611: int - test1612: int - test1613: int - test1614: int - test1615: int - test1616: int - test1617: int - test1618: int - test1619: int - test1620: int - test1621: int - test1622: int - test1623: int - test1624: int - test1625: int - test1626: int - test1627: int - test1628: int - test1629: int - test1630: int - test1631: int - test1632: int - test1633: int - test1634: int - test1635: int - test1636: int - test1637: int - test1638: int - test1639: int - test1640: int - test1641: int - test1642: int - test1643: int - test1644: int - test1645: int - test1646: int - test1647: int - test1648: int - test1649: int - test1650: int - test1651: int - test1652: int - test1653: int - test1654: int - test1655: int - test1656: int - test1657: int - test1658: int - test1659: int - test1660: int - test1661: int - test1662: int - test1663: int - test1664: int - test1665: int - test1666: int - test1667: int - test1668: int - test1669: int - test1670: int - test1671: int - test1672: int - test1673: int - test1674: int - test1675: int - test1676: int - test1677: int - test1678: int - test1679: int - test1680: int - test1681: int - test1682: int - test1683: int - test1684: int - test1685: int - test1686: int - test1687: int - test1688: int - test1689: int - test1690: int - test1691: int - test1692: int - test1693: int - test1694: int - test1695: int - test1696: int - test1697: int - test1698: int - test1699: int - test1700: int - test1701: int - test1702: int - test1703: int - test1704: int - test1705: int - test1706: int - test1707: int - test1708: int - test1709: int - test1710: int - test1711: int - test1712: int - test1713: int - test1714: int - test1715: int - test1716: int - test1717: int - test1718: int - test1719: int - test1720: int - test1721: int - test1722: int - test1723: int - test1724: int - test1725: int - test1726: int - test1727: int - test1728: int - test1729: int - test1730: int - test1731: int - test1732: int - test1733: int - test1734: int - test1735: int - test1736: int - test1737: int - test1738: int - test1739: int - test1740: int - test1741: int - test1742: int - test1743: int - test1744: int - test1745: int - test1746: int - test1747: int - test1748: int - test1749: int - test1750: int - test1751: int - test1752: int - test1753: int - test1754: int - test1755: int - test1756: int - test1757: int - test1758: int - test1759: int - test1760: int - test1761: int - test1762: int - test1763: int - test1764: int - test1765: int - test1766: int - test1767: int - test1768: int - test1769: int - test1770: int - test1771: int - test1772: int - test1773: int - test1774: int - test1775: int - test1776: int - test1777: int - test1778: int - test1779: int - test1780: int - test1781: int - test1782: int - test1783: int - test1784: int - test1785: int - test1786: int - test1787: int - test1788: int - test1789: int - test1790: int - test1791: int - test1792: int - test1793: int - test1794: int - test1795: int - test1796: int - test1797: int - test1798: int - test1799: int - test1800: int - test1801: int - test1802: int - test1803: int - test1804: int - test1805: int - test1806: int - test1807: int - test1808: int - test1809: int - test1810: int - test1811: int - test1812: int - test1813: int - test1814: int - test1815: int - test1816: int - test1817: int - test1818: int - test1819: int - test1820: int - test1821: int - test1822: int - test1823: int - test1824: int - test1825: int - test1826: int - test1827: int - test1828: int - test1829: int - test1830: int - test1831: int - test1832: int - test1833: int - test1834: int - test1835: int - test1836: int - test1837: int - test1838: int - test1839: int - test1840: int - test1841: int - test1842: int - test1843: int - test1844: int - test1845: int - test1846: int - test1847: int - test1848: int - test1849: int - test1850: int - test1851: int - test1852: int - test1853: int - test1854: int - test1855: int - test1856: int - test1857: int - test1858: int - test1859: int - test1860: int - test1861: int - test1862: int - test1863: int - test1864: int - test1865: int - test1866: int - test1867: int - test1868: int - test1869: int - test1870: int - test1871: int - test1872: int - test1873: int - test1874: int - test1875: int - test1876: int - test1877: int - test1878: int - test1879: int - test1880: int - test1881: int - test1882: int - test1883: int - test1884: int - test1885: int - test1886: int - test1887: int - test1888: int - test1889: int - test1890: int - test1891: int - test1892: int - test1893: int - test1894: int - test1895: int - test1896: int - test1897: int - test1898: int - test1899: int - test1900: int - test1901: int - test1902: int - test1903: int - test1904: int - test1905: int - test1906: int - test1907: int - test1908: int - test1909: int - test1910: int - test1911: int - test1912: int - test1913: int - test1914: int - test1915: int - test1916: int - test1917: int - test1918: int - test1919: int - test1920: int - test1921: int - test1922: int - test1923: int - test1924: int - test1925: int - test1926: int - test1927: int - test1928: int - test1929: int - test1930: int - test1931: int - test1932: int - test1933: int - test1934: int - test1935: int - test1936: int - test1937: int - test1938: int - test1939: int - test1940: int - test1941: int - test1942: int - test1943: int - test1944: int - test1945: int - test1946: int - test1947: int - test1948: int - test1949: int - test1950: int - test1951: int - test1952: int - test1953: int - test1954: int - test1955: int - test1956: int - test1957: int - test1958: int - test1959: int - test1960: int - test1961: int - test1962: int - test1963: int - test1964: int - test1965: int - test1966: int - test1967: int - test1968: int - test1969: int - test1970: int - test1971: int - test1972: int - test1973: int - test1974: int - test1975: int - test1976: int - test1977: int - test1978: int - test1979: int - test1980: int - test1981: int - test1982: int - test1983: int - test1984: int - test1985: int - test1986: int - test1987: int - test1988: int - test1989: int - test1990: int - test1991: int - test1992: int - test1993: int - test1994: int - test1995: int - test1996: int - test1997: int - test1998: int - test1999: int } [] From d22a01844e93bd607cbe640451723d87f1514438 Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 18:48:39 -0700 Subject: [PATCH 20/68] Do not delay lambda generation for now --- src/fsharp/IlxGen.fs | 8 +------- tests/fsharp/Compiler/CompilerAssert.fs | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 6d9dedc737b..cfaccfbe6c4 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4383,9 +4383,6 @@ and GenGenericParams cenv eenv tps = and GenGenericArgs m (tyenv: TypeReprEnv) tps = tps |> DropErasedTypars |> List.map (fun c -> (mkILTyvarTy tyenv.[c, m])) -and DelayGenMethodForLambda cenv mgbuf eenv args = - cenv.delayedGenMethods.Enqueue(fun cenv -> GenMethodForLambda cenv mgbuf eenv args) - and GenMethodForLambda cenv mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) = let g = cenv.g let ilCloBody = CodeGenMethodForExpr cenv mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return) @@ -4453,10 +4450,7 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr | Some v -> [(v, BranchCallClosure (cloinfo.cloArityInfo))] | _ -> [] - if cenv.exprRecursionDepth > 0 then - DelayGenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) - else - GenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) + GenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) cloinfo, m | _ -> failwith "GenLambda: not a lambda" diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index 50102ab21c4..f4f5e008f00 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -143,7 +143,7 @@ let main argv = 0""" ProjectId = None SourceFiles = [|"test.fs"|] #if !NETCOREAPP - OtherOptions = [|"--preferreduilang:en-US";"--warn:5"|] + OtherOptions = [|"--preferreduilang:en-US";"--warn:5";"--optimize-"|] #else OtherOptions = let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x) From 1fe8051232b9e0617dba11587197b12c5b6dfb3c Mon Sep 17 00:00:00 2001 From: TIHan Date: Wed, 30 Oct 2019 18:53:09 -0700 Subject: [PATCH 21/68] Get rid of optimize flag in test --- tests/fsharp/Compiler/CompilerAssert.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharp/Compiler/CompilerAssert.fs b/tests/fsharp/Compiler/CompilerAssert.fs index f4f5e008f00..50102ab21c4 100644 --- a/tests/fsharp/Compiler/CompilerAssert.fs +++ b/tests/fsharp/Compiler/CompilerAssert.fs @@ -143,7 +143,7 @@ let main argv = 0""" ProjectId = None SourceFiles = [|"test.fs"|] #if !NETCOREAPP - OtherOptions = [|"--preferreduilang:en-US";"--warn:5";"--optimize-"|] + OtherOptions = [|"--preferreduilang:en-US";"--warn:5"|] #else OtherOptions = let assemblies = getNetCoreAppReferences |> Array.map (fun x -> sprintf "-r:%s" x) From d3a2f7b1985923aeda9fe027d3730b51c283539c Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Thu, 31 Oct 2019 05:00:34 +0300 Subject: [PATCH 22/68] Type check: recover in Set expressions when left side value is not mutable (#7682) * Recover ValNoMutable and PropertyCannotBeSet errors * Recover FieldNotMutable error * Refactor tests * Refactor tests * Update baseline --- src/fsharp/MethodCalls.fs | 3 ++- src/fsharp/TypeChecker.fs | 28 ++++++++++++------------ tests/fsharp/core/span/test3.bsl | 2 +- tests/service/Common.fs | 29 +++++++++++++++++++++++++ tests/service/EditorTests.fs | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 16 deletions(-) diff --git a/src/fsharp/MethodCalls.fs b/src/fsharp/MethodCalls.fs index fdae67c6ad5..37f031e7824 100644 --- a/src/fsharp/MethodCalls.fs +++ b/src/fsharp/MethodCalls.fs @@ -1638,5 +1638,6 @@ let MethInfoChecks g amap isInstance tyargsOpt objArgs ad m (minfo: MethInfo) = exception FieldNotMutable of DisplayEnv * Tast.RecdFieldRef * range let CheckRecdFieldMutation m denv (rfinfo: RecdFieldInfo) = - if not rfinfo.RecdField.IsMutable then error (FieldNotMutable(denv, rfinfo.RecdFieldRef, m)) + if not rfinfo.RecdField.IsMutable then + errorR (FieldNotMutable (denv, rfinfo.RecdFieldRef, m)) diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 4181cb846ce..978949fd478 100644 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -9362,7 +9362,8 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del if isByrefTy g vty then destByrefTy g vty else - if not vref.IsMutable then error (ValNotMutable(env.DisplayEnv, vref, mStmt)) + if not vref.IsMutable then + errorR (ValNotMutable (env.DisplayEnv, vref, mStmt)) vty // Always allow subsumption on assignment to fields let e2', tpenv = TcExprFlex cenv true false vty2 env tpenv e2 @@ -9415,15 +9416,15 @@ and TcItemThen cenv overallTy env tpenv (item, mItem, rest, afterResolution) del if meths.IsEmpty then let meths = pinfos |> GettersOfPropInfos let isByrefMethReturnSetter = meths |> List.exists (function (_,Some pinfo) -> isByrefTy g (pinfo.GetPropertyType(cenv.amap,mItem)) | _ -> false) - if isByrefMethReturnSetter then - // x.P <- ... byref setter - if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable nm, mItem)) - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mItem mItem nm ad NeverMutates true meths afterResolution NormalValUse args ExprAtomicFlag.Atomic delayed - else - error (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) + if not isByrefMethReturnSetter then + errorR (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) + // x.P <- ... byref setter + if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable nm, mItem)) + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mItem mItem nm ad NeverMutates true meths afterResolution NormalValUse args ExprAtomicFlag.Atomic delayed else let args = if pinfo.IsIndexer then args else [] - if isNil meths then error (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) + if isNil meths then + errorR (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) // Note: static calls never mutate a struct object argument TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt [] mStmt mItem nm ad NeverMutates true meths afterResolution NormalValUse (args@[e2]) ExprAtomicFlag.NonAtomic otherDelayed | _ -> @@ -9600,12 +9601,11 @@ and TcLookupThen cenv overallTy env tpenv mObjExpr objExpr objExprTy longId dela if meths.IsEmpty then let meths = pinfos |> GettersOfPropInfos let isByrefMethReturnSetter = meths |> List.exists (function (_,Some pinfo) -> isByrefTy cenv.g (pinfo.GetPropertyType(cenv.amap,mItem)) | _ -> false) - if isByrefMethReturnSetter then - // x.P <- ... byref setter - if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable nm, mItem)) - TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem nm ad PossiblyMutates true meths afterResolution NormalValUse args atomicFlag delayed - else - error (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) + if not isByrefMethReturnSetter then + errorR (Error (FSComp.SR.tcPropertyCannotBeSet1 nm, mItem)) + // x.P <- ... byref setter + if isNil meths then error (Error (FSComp.SR.tcPropertyIsNotReadable nm, mItem)) + TcMethodApplicationThen cenv env overallTy None tpenv tyargsOpt objArgs mExprAndItem mItem nm ad PossiblyMutates true meths afterResolution NormalValUse args atomicFlag delayed else let args = if pinfo.IsIndexer then args else [] let mut = (if isStructTy cenv.g (tyOfExpr cenv.g objExpr) then DefinitelyMutates else PossiblyMutates) diff --git a/tests/fsharp/core/span/test3.bsl b/tests/fsharp/core/span/test3.bsl index cb284695276..1e6859edcc6 100644 --- a/tests/fsharp/core/span/test3.bsl +++ b/tests/fsharp/core/span/test3.bsl @@ -10,5 +10,5 @@ test3.fsx(47,21,47,27): typecheck error FS0027: This value is not mutable. Consi test3.fsx(46,26,46,27): typecheck error FS0193: Type constraint mismatch. The type 'Span' is not compatible with type - 'seq<'a>' + 'seq' diff --git a/tests/service/Common.fs b/tests/service/Common.fs index 946995e4c17..163e70bb096 100644 --- a/tests/service/Common.fs +++ b/tests/service/Common.fs @@ -5,6 +5,7 @@ open System.IO open System.Collections.Generic open FSharp.Compiler open FSharp.Compiler.SourceCodeServices +open FsUnit #if NETCOREAPP2_0 let readRefs (folder : string) (projectFile: string) = @@ -304,6 +305,34 @@ let rec allSymbolsInEntities compGen (entities: IList) = yield! allSymbolsInEntities compGen e.NestedEntities ] +let getSymbolUses (source: string) = + let _, typeCheckResults = parseAndCheckScript("/home/user/Test.fsx", source) + typeCheckResults.GetAllUsesOfAllSymbolsInFile() |> Async.RunSynchronously + +let getSymbols (source: string) = + getSymbolUses source + |> Array.map (fun symbolUse -> symbolUse.Symbol) + + +let getSymbolName (symbol: FSharpSymbol) = + match symbol with + | :? FSharpMemberOrFunctionOrValue as mfv -> Some mfv.LogicalName + | :? FSharpEntity as entity -> Some entity.LogicalName + | :? FSharpGenericParameter as parameter -> Some parameter.Name + | :? FSharpParameter as parameter -> parameter.Name + | :? FSharpStaticParameter as parameter -> Some parameter.Name + | :? FSharpActivePatternCase as case -> Some case.Name + | :? FSharpUnionCase as case -> Some case.Name + | _ -> None + + +let assertContainsSymbolWithName name source = + getSymbols source + |> Array.choose getSymbolName + |> Array.contains name + |> shouldEqual true + + let coreLibAssemblyName = #if NETCOREAPP2_0 "System.Runtime" diff --git a/tests/service/EditorTests.fs b/tests/service/EditorTests.fs index 69b9e407645..7cf404fdf39 100644 --- a/tests/service/EditorTests.fs +++ b/tests/service/EditorTests.fs @@ -1319,3 +1319,40 @@ let ``FSharpField.IsNameGenerated`` () = "type U = Case of string * Item2: string * string * Name: string", ["Item1", true; "Item2", false; "Item3", true; "Name", false]] |> List.iter (fun (source, expected) -> checkFields source |> shouldEqual expected) + + +[] +let ``ValNoMutable recovery`` () = + let source = """ +let x = 1 +x <- + let y = 1 + y +""" + assertContainsSymbolWithName "y" source + + +[] +let ``PropertyCannotBeSet recovery`` () = + let source = """ +type T = + static member P = 1 + +T.P <- + let y = 1 + y +""" + assertContainsSymbolWithName "y" source + + +[] +let ``FieldNotMutable recovery`` () = + let source = """ +type R = + { F: int } + +{ F = 1 }.F <- + let y = 1 + y +""" + assertContainsSymbolWithName "y" source From fa6e7ccdc91ea1f4afbc546d5ab0153a3eec8396 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Thu, 31 Oct 2019 05:07:32 +0300 Subject: [PATCH 23/68] Moved CodeGen/EmittedIL/TailCalls over to NUnit (#7386) * TailCalls test migration * fix the diff in IL * fix for netcore --- .../Compiler/CodeGen/EmittedIL/TailCalls.fs | 253 ++++++++++++++++++ tests/fsharp/Compiler/ILChecker.fs | 2 +- tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../CodeGen/EmittedIL/TailCalls/TailCall01.fs | 4 - .../EmittedIL/TailCalls/TailCall01.il.bsl | 111 -------- .../CodeGen/EmittedIL/TailCalls/TailCall02.fs | 5 - .../EmittedIL/TailCalls/TailCall02.il.bsl | 97 ------- .../CodeGen/EmittedIL/TailCalls/TailCall03.fs | 4 - .../EmittedIL/TailCalls/TailCall03.il.bsl | 120 --------- .../CodeGen/EmittedIL/TailCalls/TailCall04.fs | 5 - .../EmittedIL/TailCalls/TailCall04.il.bsl | 112 -------- .../CodeGen/EmittedIL/TailCalls/TailCall05.fs | 4 - .../EmittedIL/TailCalls/TailCall05.il.bsl | 118 -------- .../CodeGen/EmittedIL/TailCalls/env.lst | 5 - .../CodeGen/EmittedIL/TailCalls/keep.lst | 1 - 15 files changed, 255 insertions(+), 587 deletions(-) create mode 100644 tests/fsharp/Compiler/CodeGen/EmittedIL/TailCalls.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.il.bsl delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.il.bsl delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.il.bsl delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.il.bsl delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.fs delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.il.bsl delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/env.lst delete mode 100644 tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/keep.lst diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/TailCalls.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/TailCalls.fs new file mode 100644 index 00000000000..a61bd24ecb6 --- /dev/null +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/TailCalls.fs @@ -0,0 +1,253 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL + +open FSharp.Compiler.UnitTests +open NUnit.Framework + +[] +module ``TailCalls`` = + // Regression test for DevDiv:72571 + + [] + let ``TailCall 01``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions [|"-g"; "--optimize-"; "--tailcalls+"|] + """ +module TailCall01 +let foo(x:int, y) = printfn "%d" x +let run() = let x = 0 in foo(x,5) + """ + (fun verifier -> verifier.VerifyIL [ + """ + .method public static void foo(int32 x, + !!a y) cil managed + { + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, + int32 V_1) + IL_0000: ldstr "%d" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: stloc.0 + IL_0010: ldarg.0 + IL_0011: stloc.1 + IL_0012: ldloc.0 + IL_0013: ldloc.1 + IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0019: pop + IL_001a: ret + } + """ + """ + .method public static void run() cil managed + { + + .maxstack 4 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: ldloc.0 + IL_0003: ldc.i4.5 + IL_0004: tail. + IL_0006: call void TailCall01::foo(int32, + !!0) + IL_000b: ret + } + """ + ]) + + [] + let ``TailCall 02``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions [|"-g"; "--optimize-"; "--tailcalls+"|] + """ +module TailCall02 +let foo(x:int byref) = x +let run() = let mutable x = 0 in foo(&x) + """ + (fun verifier -> verifier.VerifyIL [ + """ + .method public static int32 foo(int32& x) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldobj [runtime]System.Int32 + IL_0006: ret + } + """ + """ + .method public static int32 run() cil managed + { + + .maxstack 3 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: call int32 TailCall02::foo(int32&) + IL_0009: ret + } + """ + ]) + + [] + let ``TailCall 03``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions [|"-g"; "--optimize-"; "--tailcalls+"|] + """ +module TailCall03 +let foo (x:int byref) (y:int byref) z = printfn "%d" (x+y) +let run() = let mutable x = 0 in foo &x &x 5 + """ + (fun verifier -> verifier.VerifyIL [ + """ + .method public static void foo(int32& x, + int32& y, + !!a z) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, + int32 V_1) + IL_0000: ldstr "%d" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: stloc.0 + IL_0010: ldarg.0 + IL_0011: ldobj [runtime]System.Int32 + IL_0016: ldarg.1 + IL_0017: ldobj [runtime]System.Int32 + IL_001c: add + IL_001d: stloc.1 + IL_001e: ldloc.0 + IL_001f: ldloc.1 + IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0025: pop + IL_0026: ret + } + """ + """ + .method public static void run() cil managed + { + + .maxstack 5 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: ldloca.s V_0 + IL_0006: ldc.i4.5 + IL_0007: call void TailCall03::foo(int32&, + int32&, + !!0) + IL_000c: nop + IL_000d: ret + } + """ + ]) + + [] + let ``TailCall 04``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions [|"-g"; "--optimize-"; "--tailcalls+"|] + """ +module TailCall04 +let foo(x:int byref, y) = printfn "%d" x +let run() = let mutable x = 0 in foo(&x,5) + """ + (fun verifier -> verifier.VerifyIL [ + """ + .method public static void foo(int32& x, + !!a y) cil managed + { + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, + int32 V_1) + IL_0000: ldstr "%d" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: stloc.0 + IL_0010: ldarg.0 + IL_0011: ldobj [runtime]System.Int32 + IL_0016: stloc.1 + IL_0017: ldloc.0 + IL_0018: ldloc.1 + IL_0019: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001e: pop + IL_001f: ret + } + """ + """ + .method public static void run() cil managed + { + + .maxstack 4 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: ldc.i4.5 + IL_0005: call void TailCall04::foo(int32&, + !!0) + IL_000a: nop + IL_000b: ret + + """ + ]) + + [] + let ``TailCall 05``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions [|"-g"; "--optimize-"; "--tailcalls+"|] + """ +module TailCall05 +let foo(x:int byref, y:int byref, z) = printfn "%d" (x+y) +let run() = let mutable x = 0 in foo(&x,&x,5) + """ + (fun verifier -> verifier.VerifyIL [ + """ + .method public static void foo(int32& x, + int32& y, + !!a z) cil managed + { + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, + int32 V_1) + IL_0000: ldstr "%d" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) + IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_000f: stloc.0 + IL_0010: ldarg.0 + IL_0011: ldobj [runtime]System.Int32 + IL_0016: ldarg.1 + IL_0017: ldobj [runtime]System.Int32 + IL_001c: add + IL_001d: stloc.1 + IL_001e: ldloc.0 + IL_001f: ldloc.1 + IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0025: pop + IL_0026: ret + } + """ + """ + .method public static void run() cil managed + { + + .maxstack 5 + .locals init (int32 V_0) + IL_0000: ldc.i4.0 + IL_0001: stloc.0 + IL_0002: ldloca.s V_0 + IL_0004: ldloca.s V_0 + IL_0006: ldc.i4.5 + IL_0007: call void TailCall05::foo(int32&, + int32&, + !!0) + IL_000c: nop + IL_000d: ret + } + """ + ]) \ No newline at end of file diff --git a/tests/fsharp/Compiler/ILChecker.fs b/tests/fsharp/Compiler/ILChecker.fs index 7f29873bc60..4558d089113 100644 --- a/tests/fsharp/Compiler/ILChecker.fs +++ b/tests/fsharp/Compiler/ILChecker.fs @@ -40,7 +40,7 @@ module ILChecker = let unifyRuntimeAssemblyName ilCode = System.Text.RegularExpressions.Regex.Replace(ilCode, - "\[System.Runtime\]|\[mscorlib\]","[runtime]", + "\[System.Runtime\]|\[System.Runtime.Extensions\]|\[mscorlib\]","[runtime]", System.Text.RegularExpressions.RegexOptions.Singleline) let text = diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 7d9b70ebe62..563358e1a1f 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -36,6 +36,7 @@ + diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.fs deleted file mode 100644 index 4a3f78fcfc0..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #NoMono #NoMT #CodeGen #EmittedIL #Tailcall -// Regression test for DevDiv:72571 -let foo(x:int, y) = printfn "%d" x -let run() = let x = 0 in foo(x,5) diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.il.bsl deleted file mode 100644 index 028bdaec338..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall01.il.bsl +++ /dev/null @@ -1,111 +0,0 @@ - -// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. All rights reserved. - - - -// Metadata version: v4.0.30319 -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .ver 4:0:0:0 -} -.assembly extern FSharp.Core -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: - .ver 4:4:1:0 -} -.assembly TailCall01 -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - // --- The following custom attribute is added automatically, do not uncomment ------- - // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 ) - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.mresource public FSharpSignatureData.TailCall01 -{ - // Offset: 0x00000000 Length: 0x0000021D -} -.mresource public FSharpOptimizationData.TailCall01 -{ - // Offset: 0x00000228 Length: 0x0000007C -} -.module TailCall01.exe -// MVID: {59B19213-7D8F-CF4A-A745-03831392B159} -.imagebase 0x00400000 -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 // WINDOWS_CUI -.corflags 0x00000001 // ILONLY -// Image base: 0x02E90000 - - -// =============== CLASS MEMBERS DECLARATION =================== - -.class public abstract auto ansi sealed TailCall01 - extends [mscorlib]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void foo(int32 x, - !!a y) cil managed - { - // Code size 27 (0x1b) - .maxstack 4 - .locals init ([0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, - [1] int32 V_1) - .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' - .line 3,3 : 21,33 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\TailCalls\\TailCall01.fs' - IL_0000: ldstr "%d" - IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) - IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_000f: stloc.0 - IL_0010: ldarg.0 - IL_0011: stloc.1 - IL_0012: ldloc.0 - IL_0013: ldloc.1 - IL_0014: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_0019: pop - IL_001a: ret - } // end of method TailCall01::foo - - .method public static void run() cil managed - { - // Code size 12 (0xc) - .maxstack 4 - .locals init ([0] int32 x) - .line 4,4 : 13,22 '' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 4,4 : 26,34 '' - IL_0002: ldloc.0 - IL_0003: ldc.i4.5 - IL_0004: tail. - IL_0006: call void TailCall01::foo(int32, - !!0) - IL_000b: ret - } // end of method TailCall01::run - -} // end of class TailCall01 - -.class private abstract auto ansi sealed ''.$TailCall01 - extends [mscorlib]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method $TailCall01::main@ - -} // end of class ''.$TailCall01 - - -// ============================================================= - -// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.fs deleted file mode 100644 index 362e37f7716..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #NoMono #NoMT #CodeGen #EmittedIL #Tailcall -// Regression test for DevDiv:72571 -let foo(x:int byref) = x -let run() = let mutable x = 0 in foo(&x) - diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.il.bsl deleted file mode 100644 index 8a7cd2907e0..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall02.il.bsl +++ /dev/null @@ -1,97 +0,0 @@ - -// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. All rights reserved. - - - -// Metadata version: v4.0.30319 -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .ver 4:0:0:0 -} -.assembly extern FSharp.Core -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: - .ver 4:4:1:0 -} -.assembly TailCall02 -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - // --- The following custom attribute is added automatically, do not uncomment ------- - // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 ) - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.mresource public FSharpSignatureData.TailCall02 -{ - // Offset: 0x00000000 Length: 0x00000202 -} -.mresource public FSharpOptimizationData.TailCall02 -{ - // Offset: 0x00000208 Length: 0x0000007C -} -.module TailCall02.exe -// MVID: {59B19213-7D8F-CE9D-A745-03831392B159} -.imagebase 0x00400000 -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 // WINDOWS_CUI -.corflags 0x00000001 // ILONLY -// Image base: 0x00E20000 - - -// =============== CLASS MEMBERS DECLARATION =================== - -.class public abstract auto ansi sealed TailCall02 - extends [mscorlib]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static int32 foo(int32& x) cil managed - { - // Code size 7 (0x7) - .maxstack 8 - .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' - .line 3,3 : 24,25 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\TailCalls\\TailCall02.fs' - IL_0000: ldarg.0 - IL_0001: ldobj [mscorlib]System.Int32 - IL_0006: ret - } // end of method TailCall02::foo - - .method public static int32 run() cil managed - { - // Code size 10 (0xa) - .maxstack 3 - .locals init ([0] int32 x) - .line 4,4 : 13,30 '' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 4,4 : 34,41 '' - IL_0002: ldloca.s x - IL_0004: call int32 TailCall02::foo(int32&) - IL_0009: ret - } // end of method TailCall02::run - -} // end of class TailCall02 - -.class private abstract auto ansi sealed ''.$TailCall02 - extends [mscorlib]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method $TailCall02::main@ - -} // end of class ''.$TailCall02 - - -// ============================================================= - -// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.fs deleted file mode 100644 index 8311ca7af25..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #NoMono #NoMT #CodeGen #EmittedIL #Tailcall -// Regression test for DevDiv:72571 -let foo (x:int byref) (y:int byref) z = printfn "%d" (x+y) -let run() = let mutable x = 0 in foo &x &x 5 diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.il.bsl deleted file mode 100644 index 0b27a3419b2..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall03.il.bsl +++ /dev/null @@ -1,120 +0,0 @@ - -// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. All rights reserved. - - - -// Metadata version: v4.0.30319 -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .ver 4:0:0:0 -} -.assembly extern FSharp.Core -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: - .ver 4:4:1:0 -} -.assembly TailCall03 -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - // --- The following custom attribute is added automatically, do not uncomment ------- - // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 ) - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.mresource public FSharpSignatureData.TailCall03 -{ - // Offset: 0x00000000 Length: 0x00000241 -} -.mresource public FSharpOptimizationData.TailCall03 -{ - // Offset: 0x00000248 Length: 0x0000007C -} -.module TailCall03.exe -// MVID: {59B19213-7D8F-CE88-A745-03831392B159} -.imagebase 0x00400000 -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 // WINDOWS_CUI -.corflags 0x00000001 // ILONLY -// Image base: 0x00E50000 - - -// =============== CLASS MEMBERS DECLARATION =================== - -.class public abstract auto ansi sealed TailCall03 - extends [mscorlib]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void foo(int32& x, - int32& y, - !!a z) cil managed - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 - 00 00 00 00 ) - // Code size 39 (0x27) - .maxstack 4 - .locals init ([0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, - [1] int32 V_1) - .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' - .line 3,3 : 41,53 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\TailCalls\\TailCall03.fs' - IL_0000: ldstr "%d" - IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) - IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_000f: stloc.0 - IL_0010: ldarg.0 - IL_0011: ldobj [mscorlib]System.Int32 - IL_0016: ldarg.1 - IL_0017: ldobj [mscorlib]System.Int32 - IL_001c: add - IL_001d: stloc.1 - IL_001e: ldloc.0 - IL_001f: ldloc.1 - IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_0025: pop - IL_0026: ret - } // end of method TailCall03::foo - - .method public static void run() cil managed - { - // Code size 14 (0xe) - .maxstack 5 - .locals init ([0] int32 x) - .line 4,4 : 13,30 '' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 4,4 : 34,45 '' - IL_0002: ldloca.s x - IL_0004: ldloca.s x - IL_0006: ldc.i4.5 - IL_0007: call void TailCall03::foo(int32&, - int32&, - !!0) - IL_000c: nop - IL_000d: ret - } // end of method TailCall03::run - -} // end of class TailCall03 - -.class private abstract auto ansi sealed ''.$TailCall03 - extends [mscorlib]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method $TailCall03::main@ - -} // end of class ''.$TailCall03 - - -// ============================================================= - -// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.fs deleted file mode 100644 index 0872b95f9c7..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #NoMono #NoMT #CodeGen #EmittedIL #Tailcall -// Regression test for DevDiv:72571 -let foo(x:int byref, y) = printfn "%d" x -let run() = let mutable x = 0 in foo(&x,5) - diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.il.bsl deleted file mode 100644 index 309f764e782..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall04.il.bsl +++ /dev/null @@ -1,112 +0,0 @@ - -// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. All rights reserved. - - - -// Metadata version: v4.0.30319 -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .ver 4:0:0:0 -} -.assembly extern FSharp.Core -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: - .ver 4:4:1:0 -} -.assembly TailCall04 -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - // --- The following custom attribute is added automatically, do not uncomment ------- - // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 ) - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.mresource public FSharpSignatureData.TailCall04 -{ - // Offset: 0x00000000 Length: 0x0000022F -} -.mresource public FSharpOptimizationData.TailCall04 -{ - // Offset: 0x00000238 Length: 0x0000007C -} -.module TailCall04.exe -// MVID: {59B19213-7D8F-CFE3-A745-03831392B159} -.imagebase 0x00400000 -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 // WINDOWS_CUI -.corflags 0x00000001 // ILONLY -// Image base: 0x00B70000 - - -// =============== CLASS MEMBERS DECLARATION =================== - -.class public abstract auto ansi sealed TailCall04 - extends [mscorlib]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void foo(int32& x, - !!a y) cil managed - { - // Code size 32 (0x20) - .maxstack 4 - .locals init ([0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, - [1] int32 V_1) - .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' - .line 3,3 : 27,39 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\TailCalls\\TailCall04.fs' - IL_0000: ldstr "%d" - IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) - IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_000f: stloc.0 - IL_0010: ldarg.0 - IL_0011: ldobj [mscorlib]System.Int32 - IL_0016: stloc.1 - IL_0017: ldloc.0 - IL_0018: ldloc.1 - IL_0019: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_001e: pop - IL_001f: ret - } // end of method TailCall04::foo - - .method public static void run() cil managed - { - // Code size 12 (0xc) - .maxstack 4 - .locals init ([0] int32 x) - .line 4,4 : 13,30 '' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 4,4 : 34,43 '' - IL_0002: ldloca.s x - IL_0004: ldc.i4.5 - IL_0005: call void TailCall04::foo(int32&, - !!0) - IL_000a: nop - IL_000b: ret - } // end of method TailCall04::run - -} // end of class TailCall04 - -.class private abstract auto ansi sealed ''.$TailCall04 - extends [mscorlib]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method $TailCall04::main@ - -} // end of class ''.$TailCall04 - - -// ============================================================= - -// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.fs b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.fs deleted file mode 100644 index 2796d18d97c..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #NoMono #NoMT #CodeGen #EmittedIL #Tailcall -// Regression test for DevDiv:72571 -let foo(x:int byref, y:int byref, z) = printfn "%d" (x+y) -let run() = let mutable x = 0 in foo(&x,&x,5) diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.il.bsl b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.il.bsl deleted file mode 100644 index 5ae3bd0b331..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/TailCall05.il.bsl +++ /dev/null @@ -1,118 +0,0 @@ - -// Microsoft (R) .NET Framework IL Disassembler. Version 4.6.1055.0 -// Copyright (c) Microsoft Corporation. All rights reserved. - - - -// Metadata version: v4.0.30319 -.assembly extern mscorlib -{ - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .ver 4:0:0:0 -} -.assembly extern FSharp.Core -{ - .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: - .ver 4:4:1:0 -} -.assembly TailCall05 -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - - // --- The following custom attribute is added automatically, do not uncomment ------- - // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 01 01 00 00 00 00 ) - - .hash algorithm 0x00008004 - .ver 0:0:0:0 -} -.mresource public FSharpSignatureData.TailCall05 -{ - // Offset: 0x00000000 Length: 0x0000023F -} -.mresource public FSharpOptimizationData.TailCall05 -{ - // Offset: 0x00000248 Length: 0x0000007C -} -.module TailCall05.exe -// MVID: {59B19213-7D8F-CFC6-A745-03831392B159} -.imagebase 0x00400000 -.file alignment 0x00000200 -.stackreserve 0x00100000 -.subsystem 0x0003 // WINDOWS_CUI -.corflags 0x00000001 // ILONLY -// Image base: 0x03210000 - - -// =============== CLASS MEMBERS DECLARATION =================== - -.class public abstract auto ansi sealed TailCall05 - extends [mscorlib]System.Object -{ - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .method public static void foo(int32& x, - int32& y, - !!a z) cil managed - { - // Code size 39 (0x27) - .maxstack 4 - .locals init ([0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 V_0, - [1] int32 V_1) - .language '{AB4F38C9-B6E6-43BA-BE3B-58080B2CCCE3}', '{994B45C4-E6E9-11D2-903F-00C04FA302A1}', '{5A869D0B-6611-11D3-BD2A-0000F80849BD}' - .line 3,3 : 40,52 'C:\\GitHub\\dsyme\\visualfsharp\\tests\\fsharpqa\\Source\\CodeGen\\EmittedIL\\TailCalls\\TailCall05.fs' - IL_0000: ldstr "%d" - IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5,class [mscorlib]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit,int32>::.ctor(string) - IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) - IL_000f: stloc.0 - IL_0010: ldarg.0 - IL_0011: ldobj [mscorlib]System.Int32 - IL_0016: ldarg.1 - IL_0017: ldobj [mscorlib]System.Int32 - IL_001c: add - IL_001d: stloc.1 - IL_001e: ldloc.0 - IL_001f: ldloc.1 - IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) - IL_0025: pop - IL_0026: ret - } // end of method TailCall05::foo - - .method public static void run() cil managed - { - // Code size 14 (0xe) - .maxstack 5 - .locals init ([0] int32 x) - .line 4,4 : 13,30 '' - IL_0000: ldc.i4.0 - IL_0001: stloc.0 - .line 4,4 : 34,46 '' - IL_0002: ldloca.s x - IL_0004: ldloca.s x - IL_0006: ldc.i4.5 - IL_0007: call void TailCall05::foo(int32&, - int32&, - !!0) - IL_000c: nop - IL_000d: ret - } // end of method TailCall05::run - -} // end of class TailCall05 - -.class private abstract auto ansi sealed ''.$TailCall05 - extends [mscorlib]System.Object -{ - .method public static void main@() cil managed - { - .entrypoint - // Code size 1 (0x1) - .maxstack 8 - IL_0000: ret - } // end of method $TailCall05::main@ - -} // end of class ''.$TailCall05 - - -// ============================================================= - -// *********** DISASSEMBLY COMPLETE *********************** diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/env.lst b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/env.lst deleted file mode 100644 index 0c87dd2fbb3..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/env.lst +++ /dev/null @@ -1,5 +0,0 @@ - SOURCE=TailCall01.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize- --tailcalls+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TailCall01.exe" # TailCall01.fs - - SOURCE=TailCall02.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize- --tailcalls+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TailCall02.exe" # TailCall02.fs - - SOURCE=TailCall03.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize- --tailcalls+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TailCall03.exe" # TailCall03.fs - - SOURCE=TailCall04.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize- --tailcalls+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TailCall04.exe" # TailCall04.fs - - SOURCE=TailCall05.fs SCFLAGS="-g --test:EmitFeeFeeAs100001 --optimize- --tailcalls+" COMPILE_ONLY=1 POSTCMD="..\\CompareIL.cmd TailCall05.exe" # TailCall05.fs - diff --git a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/keep.lst b/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/keep.lst deleted file mode 100644 index f59ec20aabf..00000000000 --- a/tests/fsharpqa/Source/CodeGen/EmittedIL/TailCalls/keep.lst +++ /dev/null @@ -1 +0,0 @@ -* \ No newline at end of file From 3b47477c1cfb70b6e2c8268e0ca6d5a3a3fcbd44 Mon Sep 17 00:00:00 2001 From: "Kevin Ransom (msft)" Date: Wed, 30 Oct 2019 19:19:01 -0700 Subject: [PATCH 24/68] Update DotNetFrameworkDependencies.fs --- src/fsharp/DotNetFrameworkDependencies.fs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index f28f125636c..8c9c98c16d3 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -6,6 +6,7 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies open System open System.Collections.Generic + open System.Globalization open System.IO open System.Reflection From a61b6f1ab6aa03949b118a017715527fa9f936b3 Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Thu, 31 Oct 2019 15:30:00 +0000 Subject: [PATCH 25/68] Delete duplicate test (#7412) * Delete duplicate test StartTask was exactly the same as CreateTask 50 lines above. * Restore poorly merged test case --- .../Microsoft.FSharp.Control/AsyncType.fs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs index 79a179bea1e..2966bf32d48 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/AsyncType.fs @@ -199,20 +199,6 @@ type AsyncType() = | _ -> reraise() Assert.IsTrue (tcs.Task.IsCompleted, "Task is not completed") - [] - member this.StartTask () = - let s = "Hello tasks!" - let a = async { return s } -#if !NET46 - let t = -#else - use t = -#endif - Async.StartAsTask a - this.WaitASec t - Assert.IsTrue (t.IsCompleted) - Assert.AreEqual(s, t.Result) - [] member this.RunSynchronouslyCancellationWithDelayedResult () = let cts = new CancellationTokenSource() From edcebae9642abae5f0419cc857aace876a07b709 Mon Sep 17 00:00:00 2001 From: Gauthier Segay Date: Thu, 31 Oct 2019 18:17:47 +0100 Subject: [PATCH 26/68] Add tests/fsharp/readme.md (#6681) * init a basic readme.md for fsharp test suite * fix title and try to add link * case sensitive? * Update layout. * Update readme.md --- tests/fsharp/readme.md | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/fsharp/readme.md diff --git a/tests/fsharp/readme.md b/tests/fsharp/readme.md new file mode 100644 index 00000000000..c12bf5a5e44 --- /dev/null +++ b/tests/fsharp/readme.md @@ -0,0 +1,67 @@ +# F# Compiler Cross-Platform Test Suite + +## Layout + +The tests are NUNIT test cases.. They test a very wide range of compiler, interactive and FSharp.Core scenarios. + +The bulk of the test cases are enumerated in tests.fs, these are the old cambridge test suite. They build on a test-suite ported from windows batch files. They run the compiler and fsi as seperate processes, when built for the coreclr it runs the coreclr versions using dotnet.exe + +The framework and utilities can be found in test-framework.fs, single-test.fs, coreclr_utilities.fs. + +test cases look similar to: +```` + [] + let ``array-FSI_BASIC`` () = singleTestBuildAndRun "core/array" FSI_BASIC +```` +This test case builds and runs the test case in the folder core/array + +this #define is used to exclude from the build tests that run will not run correctly on the coreclr +__#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS__ + +There are some older tests in this section that looks similar to: +```` + [] + let events () = + let cfg = testConfig "core/events" + fsc cfg "%s -a -o:test.dll -g" cfg.fsc_flags ["test.fs"] + peverify cfg "test.dll" + csc cfg """/r:"%s" /reference:test.dll /debug+""" cfg.FSCOREDLLPATH ["testcs.cs"] + peverify cfg "testcs.exe" + use testOkFile = fileguard cfg "test.ok" + fsi cfg "" ["test.fs"] + testOkFile.CheckExists() + exec cfg ("." ++ "testcs.exe") "" +```` +These tests build, compile, peverify and run fsi. + +Below the Compiler directory there is a set of tests built on the compiler service. They are nunit and instead of executing the compiler and fsi using files on disk the tests are built from memory. These tests use the CompilerAssert framework and look similar to: + +This test verifies that a warning is produces when a value is implicitly discarded. The line ````x = 20``` looks like an assignment but in F# is a test for equality it yields and discards the value false. +```` + [] + let ``Unused compare with immutable when assignment might be intended``() = + CompilerAssert.TypeCheckSingleError + """ +let x = 10 +let y = "hello" + +let changeX() = + x = 20 + y = "test" + """ + FSharpErrorSeverity.Warning + 20 + (6, 5, 6, 11) + "The result of this equality expression has type 'bool' and is implicitly discarded. Consider using 'let' to bind the result to a name, e.g. 'let result = expression'. If you intended to mutate a value, then mark the value 'mutable' and use the '<-' operator e.g. 'x <- expression'." +```` + + +## Workflow when adding or fixing tests + +When a test is run, .err/.vserr output files are created and compared to their matching .bsl files. + +When many tests fail due to a change being worked on, the [update.base.line.with.actuals.fsx](update.base.line.with.actuals.fsx) script helps updating the .bsl against the actuals. + +After editing the folder list, evaluating the script should replace the .bsl files with actual .err/.vserr, after which the same test is supposed to pass. + +Tests are organized under modules as functions bearing NUnit `[]` attribute and can be run from an IDE or the command line (see the [Test Guide](../../TESTGUIDE.md)). From eb333d994edd76d5595e63a565aa77a7994211b7 Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 18:08:15 -0700 Subject: [PATCH 27/68] Removed unrelated code changes to the fix --- src/fsharp/CompileOptions.fs | 2 +- src/fsharp/IlxGen.fs | 107 +++++++++++++++++------------------ src/fsharp/Optimizer.fs | 14 ++--- src/fsharp/Optimizer.fsi | 6 +- 4 files changed, 60 insertions(+), 69 deletions(-) diff --git a/src/fsharp/CompileOptions.fs b/src/fsharp/CompileOptions.fs index c7ef18c94b8..c4595d2dc24 100644 --- a/src/fsharp/CompileOptions.fs +++ b/src/fsharp/CompileOptions.fs @@ -395,7 +395,7 @@ let SetOptimizeOn(tcConfigB: TcConfigBuilder) = tcConfigB.optSettings <- { tcConfigB.optSettings with jitOptUser = Some true } tcConfigB.optSettings <- { tcConfigB.optSettings with localOptUser = Some true } tcConfigB.optSettings <- { tcConfigB.optSettings with crossModuleOptUser = Some true } - tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = Optimizer.LambdaInlineThresholdDefault } + tcConfigB.optSettings <- { tcConfigB.optSettings with lambdaInlineThreshold = 6 } tcConfigB.doDetuple <- true tcConfigB.doTLR <- true tcConfigB.doFinalSimplify <- true diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index cfaccfbe6c4..bb8468443b9 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4383,62 +4383,9 @@ and GenGenericParams cenv eenv tps = and GenGenericArgs m (tyenv: TypeReprEnv) tps = tps |> DropErasedTypars |> List.map (fun c -> (mkILTyvarTy tyenv.[c, m])) -and GenMethodForLambda cenv mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) = - let g = cenv.g - let ilCloBody = CodeGenMethodForExpr cenv mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return) - let ilCloTypeRef = cloinfo.cloSpec.TypeRef - let cloTypeDefs = - if isLocalTypeFunc then - - // Work out the contract type and generate a class with an abstract method for this type - let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo - let ilContractTypeRef = ilContractTySpec.TypeRef - let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams - let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object - - let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ] - let ilContractTypeDef = - ILTypeDef(name = ilContractTypeRef.Name, - layout = ILTypeDefLayout.Auto, - attributes = enum 0, - genericParams = ilContractGenericParams, - customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ], - fields = emptyILFields, - events= emptyILEvents, - properties = emptyILProperties, - methods= mkILMethods ilContractMeths, - methodImpls= emptyILMethodImpls, - nestedTypes=emptyILTypeDefs, - implements = [], - extends= Some g.ilg.typ_Object, - securityDecls= emptyILSecurityDecls) - - // the contract type is an abstract type and not sealed - let ilContractTypeDef = - ilContractTypeDef - .WithAbstract(true) - .WithAccess(ComputeTypeAccess ilContractTypeRef true) - .WithSerializable(true) - .WithSpecialName(true) - .WithLayout(ILTypeDefLayout.Auto) - .WithInitSemantics(ILTypeInit.BeforeField) - .WithEncoding(ILDefaultPInvokeEncoding.Auto) - - mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None) - - let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None ) - let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ] - let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, []) - cloTypeDefs - - else - GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, []) - CountClosure() - for cloTypeDef in cloTypeDefs do - mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None) - /// Generate the closure class for a function and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr = + let g = cenv.g match expr with | Expr.Lambda (_, _, _, _, _, m, _) | Expr.TyLambda (_, _, _, m, _) -> @@ -4450,7 +4397,57 @@ and GenLambdaClosure cenv (cgbuf: CodeGenBuffer) eenv isLocalTypeFunc selfv expr | Some v -> [(v, BranchCallClosure (cloinfo.cloArityInfo))] | _ -> [] - GenMethodForLambda cenv cgbuf.mgbuf eenv (entryPointInfo, cloinfo, eenvinner, body, isLocalTypeFunc, m) + let ilCloBody = CodeGenMethodForExpr cenv cgbuf.mgbuf (SPAlways, entryPointInfo, cloinfo.cloName, eenvinner, 1, body, Return) + let ilCloTypeRef = cloinfo.cloSpec.TypeRef + let cloTypeDefs = + if isLocalTypeFunc then + + // Work out the contract type and generate a class with an abstract method for this type + let (ilContractGenericParams, ilContractMethTyargs, ilContractTySpec: ILTypeSpec, ilContractFormalRetTy) = GenNamedLocalTypeFuncContractInfo cenv eenv m cloinfo + let ilContractTypeRef = ilContractTySpec.TypeRef + let ilContractTy = mkILFormalBoxedTy ilContractTypeRef ilContractGenericParams + let ilContractCtor = mkILNonGenericEmptyCtor None g.ilg.typ_Object + + let ilContractMeths = [ilContractCtor; mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, ilContractMethTyargs, [], mkILReturn ilContractFormalRetTy, MethodBody.Abstract) ] + let ilContractTypeDef = + ILTypeDef(name = ilContractTypeRef.Name, + layout = ILTypeDefLayout.Auto, + attributes = enum 0, + genericParams = ilContractGenericParams, + customAttrs = mkILCustomAttrs [mkCompilationMappingAttr g (int SourceConstructFlags.Closure) ], + fields = emptyILFields, + events= emptyILEvents, + properties = emptyILProperties, + methods= mkILMethods ilContractMeths, + methodImpls= emptyILMethodImpls, + nestedTypes=emptyILTypeDefs, + implements = [], + extends= Some g.ilg.typ_Object, + securityDecls= emptyILSecurityDecls) + + // the contract type is an abstract type and not sealed + let ilContractTypeDef = + ilContractTypeDef + .WithAbstract(true) + .WithAccess(ComputeTypeAccess ilContractTypeRef true) + .WithSerializable(true) + .WithSpecialName(true) + .WithLayout(ILTypeDefLayout.Auto) + .WithInitSemantics(ILTypeInit.BeforeField) + .WithEncoding(ILDefaultPInvokeEncoding.Auto) + + cgbuf.mgbuf.AddTypeDef(ilContractTypeRef, ilContractTypeDef, false, false, None) + + let ilCtorBody = mkILMethodBody (true, [], 8, nonBranchingInstrsToCode (mkCallBaseConstructor(ilContractTy, [])), None ) + let cloMethods = [ mkILGenericVirtualMethod("DirectInvoke", ILMemberAccess.Assembly, cloinfo.localTypeFuncDirectILGenericParams, [], mkILReturn (cloinfo.cloILFormalRetTy), MethodBody.IL ilCloBody) ] + let cloTypeDefs = GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCtorBody, cloMethods, [], ilContractTy, []) + cloTypeDefs + + else + GenClosureTypeDefs cenv (ilCloTypeRef, cloinfo.cloILGenericParams, [], cloinfo.cloILFreeVars, cloinfo.ilCloLambdas, ilCloBody, [], [], g.ilg.typ_Object, []) + CountClosure() + for cloTypeDef in cloTypeDefs do + cgbuf.mgbuf.AddTypeDef(ilCloTypeRef, cloTypeDef, false, false, None) cloinfo, m | _ -> failwith "GenLambda: not a lambda" diff --git a/src/fsharp/Optimizer.fs b/src/fsharp/Optimizer.fs index f4c1a4c95a9..e89f3e4284b 100644 --- a/src/fsharp/Optimizer.fs +++ b/src/fsharp/Optimizer.fs @@ -278,8 +278,6 @@ let [] localOptDefault = true let [] crossModuleOptDefault = true -let [] LambdaInlineThresholdDefault = 6 - type OptimizationSettings = { abstractBigTargets : bool @@ -317,7 +315,7 @@ type OptimizationSettings = bigTargetSize = 100 veryBigExprSize = 3000 crossModuleOptUser = None - lambdaInlineThreshold = LambdaInlineThresholdDefault + lambdaInlineThreshold = 6 reportingPhase = false reportNoNeedToTailcall = false reportFunctionSizes = false @@ -1934,7 +1932,7 @@ let rec OptimizeExpr cenv (env: IncrementalOptimizationEnv) expr = /// Optimize/analyze an object expression and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m) = let basecallR, basecallinfo = OptimizeExpr cenv env basecall - let overridesR, overrideinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides + let overridesR, overrideinfos = OptimizeMethods cenv env baseValOpt overrides let iimplsR, iimplsinfos = OptimizeInterfaceImpls cenv env baseValOpt iimpls let exprR=mkObjExpr(ty, baseValOpt, basecallR, overridesR, iimplsR, m) exprR, { TotalSize=closureTotalSize + basecallinfo.TotalSize + AddTotalSizes overrideinfos + AddTotalSizes iimplsinfos @@ -1944,10 +1942,10 @@ and OptimizeObjectExpr cenv env (ty, baseValOpt, basecall, overrides, iimpls, m) Info=UnknownValue} /// Optimize/analyze the methods that make up an object expression -and OptimizeObjectExprMethods cenv env baseValOpt methods = - OptimizeList (OptimizeObjectExprMethod cenv env baseValOpt) methods +and OptimizeMethods cenv env baseValOpt methods = + OptimizeList (OptimizeMethod cenv env baseValOpt) methods -and OptimizeObjectExprMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) = +and OptimizeMethod cenv env baseValOpt (TObjExprMethod(slotsig, attribs, tps, vs, e, m) as tmethod) = let env = {env with latestBoundId=Some tmethod.Id; functionVal = None} let env = BindTypeVarsToUnknown tps env let env = BindInternalValsToUnknown cenv vs env @@ -1967,7 +1965,7 @@ and OptimizeInterfaceImpls cenv env baseValOpt iimpls = /// Optimize/analyze the interface implementations that form part of an object expression and OptimizeInterfaceImpl cenv env baseValOpt (ty, overrides) = - let overridesR, overridesinfos = OptimizeObjectExprMethods cenv env baseValOpt overrides + let overridesR, overridesinfos = OptimizeMethods cenv env baseValOpt overrides (ty, overridesR), { TotalSize = AddTotalSizes overridesinfos FunctionSize = 1 diff --git a/src/fsharp/Optimizer.fsi b/src/fsharp/Optimizer.fsi index d489878da1a..bd656614bf4 100644 --- a/src/fsharp/Optimizer.fsi +++ b/src/fsharp/Optimizer.fsi @@ -61,8 +61,4 @@ val UnionOptimizationInfos: seq -> CcuOptimizationInfo /// Check if an expression has an effect val ExprHasEffect: TcGlobals -> Expr -> bool -val internal u_CcuOptimizationInfo : TastPickle.ReaderState -> CcuOptimizationInfo - -// REVIEW: We need to put the literal at the end of a file due to a bug that causes a compiler error when a literal is put in the middle other signature constructs. -[] -val LambdaInlineThresholdDefault : int = 6 \ No newline at end of file +val internal u_CcuOptimizationInfo : TastPickle.ReaderState -> CcuOptimizationInfo \ No newline at end of file From 02b41ce378627288ccd167bf52bb8d3b0f059f2a Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 18:11:02 -0700 Subject: [PATCH 28/68] Removed rest of unrelated code changes to fix --- src/fsharp/IlxGen.fs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index bb8468443b9..3e648efe092 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -847,14 +847,14 @@ and IlxGenEnv = withinSEH: bool /// Are we inside of a recursive let binding, while loop, or a for loop? - inLoop: bool + isInLoop: bool } override __.ToString() = "" -let SetInLoop inLoop eenv = - if eenv.inLoop = inLoop then eenv - else { eenv with inLoop = inLoop } +let SetIsInLoop isInLoop eenv = + if eenv.isInLoop = isInLoop then eenv + else { eenv with isInLoop = isInLoop } let ReplaceTyenv tyenv (eenv: IlxGenEnv) = {eenv with tyenv = tyenv } @@ -1911,9 +1911,9 @@ let CodeGenThen cenv mgbuf (entryPointInfo, methodName, eenv, alreadyUsedArgs, c let innerVals = entryPointInfo |> List.map (fun (v, kind) -> (v, (kind, start))) (* Call the given code generator *) - codeGenFunction cgbuf { eenv with withinSEH = false - liveLocals = IntMap.empty() - innerVals = innerVals } + codeGenFunction cgbuf {eenv with withinSEH=false + liveLocals=IntMap.empty() + innerVals = innerVals} let locals, maxStack, lab2pc, code, exnSpecs, hasSequencePoints = cgbuf.Close() @@ -3535,7 +3535,7 @@ and GenTryFinally cenv cgbuf eenv (bodyExpr, handlerExpr, m, resty, spTry, spFin //-------------------------------------------------------------------------- and GenForLoop cenv cgbuf eenv (spFor, v, e1, dir, e2, loopBody, m) sequel = - let eenv = SetInLoop true eenv + let eenv = SetIsInLoop true eenv let g = cenv.g // The JIT/NGen eliminate array-bounds checks for C# loops of form: @@ -3626,7 +3626,7 @@ and GenForLoop cenv cgbuf eenv (spFor, v, e1, dir, e2, loopBody, m) sequel = //-------------------------------------------------------------------------- and GenWhileLoop cenv cgbuf eenv (spWhile, e1, e2, m) sequel = - let eenv = SetInLoop true eenv + let eenv = SetIsInLoop true eenv let finish = CG.GenerateDelayMark cgbuf "while_finish" let startTest = CG.GenerateMark cgbuf "startTest" @@ -5193,7 +5193,7 @@ and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFi /// Generate letrec bindings and GenLetRecBindings cenv (cgbuf: CodeGenBuffer) eenv (allBinds: Bindings, m) = - let eenv = SetInLoop true eenv + let eenv = SetIsInLoop true eenv // Fix up recursion for non-toplevel recursive bindings let bindsPossiblyRequiringFixup = allBinds |> List.filter (fun b -> @@ -5443,7 +5443,7 @@ and GenBindingAfterSequencePoint cenv cgbuf eenv sp (TBind(vspec, rhsExpr, _)) s let storage = StorageForVal cenv.g m vspec eenv match storage, rhsExpr with // locals are zero-init, no need to initialize them, except if you are in a loop and the local is mutable. - | Local (_, realloc, _), Expr.Const (Const.Zero, _, _) when not realloc && not (eenv.inLoop && vspec.IsMutable) -> + | Local (_, realloc, _), Expr.Const (Const.Zero, _, _) when not realloc && not (eenv.isInLoop && vspec.IsMutable) -> CommitStartScope cgbuf startScopeMarkOpt | _ -> GenBindingRhs cenv cgbuf eenv SPSuppress vspec rhsExpr @@ -7578,7 +7578,7 @@ let GetEmptyIlxGenEnv (ilg: ILGlobals) ccu = innerVals = [] sigToImplRemapInfo = [] (* "module remap info" *) withinSEH = false - inLoop = false } + isInLoop = false } type IlxGenResults = { ilTypeDefs: ILTypeDef list From 8ddce9128e6277aaca107deb3057c36312e3e5c5 Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 18:18:08 -0700 Subject: [PATCH 29/68] Removed quadratic append --- src/fsharp/IlxGen.fs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 3e648efe092..d2a3c04cbb5 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -5121,13 +5121,14 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau and GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases = assert(cgbuf.GetCurrentStack() = stackAtTargets) // cgbuf stack should be unchanged over tests. [bug://1750]. - let decisions = + let defaultDecisions = match defaultTargetOpt with | Some defaultTarget -> [(None, eenv, defaultTarget)] | None -> [] - (decisions, caseLabels, cases) - |||> List.fold2 (fun decisions caseLabel (TCase(_, caseTree)) -> decisions @ [(Some caseLabel, eenv, caseTree)]) + (caseLabels, cases) + ||> List.map2 (fun caseLabel (TCase(_, caseTree)) -> (Some caseLabel, eenv, caseTree)) + |> List.append defaultDecisions // Used for the peephole optimization below and (|BoolExpr|_|) = function Expr.Const (Const.Bool b1, _, _) -> Some b1 | _ -> None From 74196aec0b46384be77d22f740631ef63adc923c Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 18:42:08 -0700 Subject: [PATCH 30/68] Moved local rec functions into top module --- src/fsharp/IlxGen.fs | 66 +++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index d2a3c04cbb5..786b60b2ab0 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4858,42 +4858,44 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = // go to the join point Br afterJoin, afterJoin, stackAfterJoin, sequel -// Accumulate the decision graph as we go -and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Queue (IlxGenEnv * EmitSequencePointState * Expr * sequel) option>) = - let rec genDecisions targetInfos decisions (queue: Queue<_>) = - match decisions with - | [] -> - let remaining = - targetInfos - |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) - |> Seq.filter (fun (KeyValue(_, (_, isTargetPostponed))) -> isTargetPostponed) - |> List.ofSeq - - let rec genRemaining remaining (queue: Queue<_>) = - match remaining with - | [] -> None - | (KeyValue(_, (targetInfo, _))) :: rest -> - queue.Enqueue(fun () -> genRemaining rest queue) - Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel) - - genRemaining remaining queue +and GenPostponedAndQueueTargets cenv cgbuf (queue: Queue<_>) targetInfos stackAtTargets sequel = + match targetInfos with + | [] -> None + | (KeyValue(_, (targetInfo, isTargetPostponed))) :: rest -> + if isTargetPostponed then + queue.Enqueue(fun () -> GenPostponedAndQueueTargets cenv cgbuf queue rest stackAtTargets sequel) + Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel) + else + GenPostponedAndQueueTargets cenv cgbuf queue rest stackAtTargets sequel + +and GenDecisionTreesAndQueueTargets cenv cgbuf (queue: Queue<_>) targetInfos decisions stackAtTargets targets repeatSP sequel = + match decisions with + | [] -> + let sortedTargetInfos = + targetInfos + |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) + |> List.ofSeq + + GenPostponedAndQueueTargets cenv cgbuf queue sortedTargetInfos stackAtTargets sequel - | (inplabOpt, eenv, tree) :: rest -> - match tree with - | TDSuccess(es, targetIdx) -> - let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel - match genTargetInfoOpt with - | Some _ -> - queue.Enqueue(fun () -> genDecisions targetInfos rest queue) - genTargetInfoOpt - | _ -> - genDecisions targetInfos rest queue + | (inplabOpt, eenv, tree) :: rest -> + match tree with + | TDSuccess(es, targetIdx) -> + let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel + match genTargetInfoOpt with + | Some _ -> + queue.Enqueue(fun () -> GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos rest stackAtTargets targets repeatSP sequel) + genTargetInfoOpt | _ -> - let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel - genDecisions targetInfos (newDecisions @ rest) queue + GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos rest stackAtTargets targets repeatSP sequel + | _ -> + let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel + GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos (newDecisions @ rest) stackAtTargets targets repeatSP sequel +// Accumulate the decision graph as we go +and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Queue (IlxGenEnv * EmitSequencePointState * Expr * sequel) option>) = let queue = Queue() - queue.Enqueue (fun () -> genDecisions (IntMap.empty()) [(None, eenv, tree)] queue) + queue.Enqueue (fun () -> GenDecisionTreesAndQueueTargets cenv cgbuf queue (IntMap.empty()) [(None, eenv, tree)] stackAtTargets targets repeatSP sequel) queue and TryFindTargetInfo targetInfos n = From e6baf7f5aae88331ac2196f595a2ea4fb5e19ed7 Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 18:55:42 -0700 Subject: [PATCH 31/68] Added GenDecisionTreeTargetQueue --- src/fsharp/IlxGen.fs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 786b60b2ab0..8e10366af6c 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2572,6 +2572,21 @@ and GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin = GenSequel cenv eenv.cloc cgbuf sequelAfterJoin +and GenDecisionTreeTargetQueue cenv cgbuf (targetQueue: Queue<_>) eenv afterJoin stackAfterJoin sequelAfterJoin contf = + if targetQueue.Count > 0 then + let f = targetQueue.Dequeue () + let genTargetInfoOpt = f () + match genTargetInfoOpt with + | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> + GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf + ) + | _ -> + GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf + else + GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin + contf Fake + and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) = let expr = stripExpr expr match expr with @@ -2661,23 +2676,7 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. // Since code is branching and joining, the cgbuf stack is maintained manually. let targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches - - let rec popTargetQueue () = - if targetQueue.Count > 0 then - let f = targetQueue.Dequeue () - let genTargetInfoOpt = f () - match genTargetInfoOpt with - | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> - GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> - popTargetQueue () - ) - | _ -> - popTargetQueue () - else - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - contf Fake - - popTargetQueue () + GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> if canProcessSequencePoint then From 8dfcc6a4eb1d34177767f5088867e90d8902e053 Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 19:54:10 -0700 Subject: [PATCH 32/68] Instead of using a queue, use CPS through other functions --- src/fsharp/IlxGen.fs | 92 ++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 54 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 8e10366af6c..4b519e6f3c8 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -2551,42 +2551,6 @@ and GenAllocUnionCase cenv cgbuf eenv (c,tyargs,args,m) sequel = GenAllocUnionCaseCore cenv cgbuf eenv (c,tyargs,args.Length,m) GenSequel cenv eenv.cloc cgbuf sequel -and GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin = - CG.SetMarkToHere cgbuf afterJoin - - //assert(cgbuf.GetCurrentStack() = stackAfterJoin) // REVIEW: Since gen_dtree* now sets stack, stack should be stackAfterJoin at this point... - CG.SetStack cgbuf stackAfterJoin - // If any values are left on the stack after the join then we're certainly going to do something with them - // For example, we may be about to execute a 'stloc' for - // - // let y2 = if System.DateTime.Now.Year < 2000 then 1 else 2 - // - // or a 'stelem' for - // - // arr.[0] <- if System.DateTime.Now.Year > 2000 then 1 else 2 - // - // In both cases, any instructions that come after this point will be falsely associated with the last branch of the control - // prior to the join point. This is base, e.g. see FSharp 1.0 bug 5155 - if not (isNil stackAfterJoin) then - cgbuf.EmitStartOfHiddenCode() - - GenSequel cenv eenv.cloc cgbuf sequelAfterJoin - -and GenDecisionTreeTargetQueue cenv cgbuf (targetQueue: Queue<_>) eenv afterJoin stackAfterJoin sequelAfterJoin contf = - if targetQueue.Count > 0 then - let f = targetQueue.Dequeue () - let genTargetInfoOpt = f () - match genTargetInfoOpt with - | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> - GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> - GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf - ) - | _ -> - GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf - else - GenAfterMatch cenv cgbuf eenv afterJoin stackAfterJoin sequelAfterJoin - contf Fake - and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: FakeUnit -> FakeUnit) = let expr = stripExpr expr match expr with @@ -2675,8 +2639,27 @@ and GenLinearExpr cenv cgbuf eenv sp expr sequel canProcessSequencePoint (contf: // match-testing (dtrees) should not contribute to the stack. // Each branch-RHS (targets) may contribute to the stack, leaving it in the "stackAfterJoin" state, for the join point. // Since code is branching and joining, the cgbuf stack is maintained manually. - let targetQueue = GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches - GenDecisionTreeTargetQueue cenv cgbuf targetQueue eenv afterJoin stackAfterJoin sequelAfterJoin contf + GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequelOnBranches (contf << (fun Fake -> + CG.SetMarkToHere cgbuf afterJoin + + //assert(cgbuf.GetCurrentStack() = stackAfterJoin) // REVIEW: Since gen_dtree* now sets stack, stack should be stackAfterJoin at this point... + CG.SetStack cgbuf stackAfterJoin + // If any values are left on the stack after the join then we're certainly going to do something with them + // For example, we may be about to execute a 'stloc' for + // + // let y2 = if System.DateTime.Now.Year < 2000 then 1 else 2 + // + // or a 'stelem' for + // + // arr.[0] <- if System.DateTime.Now.Year > 2000 then 1 else 2 + // + // In both cases, any instructions that come after this point will be falsely associated with the last branch of the control + // prior to the join point. This is base, e.g. see FSharp 1.0 bug 5155 + if not (isNil stackAfterJoin) then + cgbuf.EmitStartOfHiddenCode() + + GenSequel cenv eenv.cloc cgbuf sequelAfterJoin + Fake)) | LinearOpExpr (TOp.UnionCase c, tyargs, argsFront, argLast, m) -> if canProcessSequencePoint then @@ -4857,17 +4840,19 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = // go to the join point Br afterJoin, afterJoin, stackAfterJoin, sequel -and GenPostponedAndQueueTargets cenv cgbuf (queue: Queue<_>) targetInfos stackAtTargets sequel = +and GenPostponedDecisionTreeTargets cenv cgbuf targetInfos stackAtTargets sequel (contf: FakeUnit -> FakeUnit) : FakeUnit = match targetInfos with - | [] -> None + | [] -> contf Fake | (KeyValue(_, (targetInfo, isTargetPostponed))) :: rest -> if isTargetPostponed then - queue.Enqueue(fun () -> GenPostponedAndQueueTargets cenv cgbuf queue rest stackAtTargets sequel) - Some(GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel) + let eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget = GenDecisionTreeTarget cenv cgbuf stackAtTargets targetInfo sequel + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> + GenPostponedDecisionTreeTargets cenv cgbuf rest stackAtTargets sequel contf + ) else - GenPostponedAndQueueTargets cenv cgbuf queue rest stackAtTargets sequel + GenPostponedDecisionTreeTargets cenv cgbuf rest stackAtTargets sequel contf -and GenDecisionTreesAndQueueTargets cenv cgbuf (queue: Queue<_>) targetInfos decisions stackAtTargets targets repeatSP sequel = +and GenDecisionTreesAndTargets cenv cgbuf targetInfos decisions stackAtTargets targets repeatSP sequel contf = match decisions with | [] -> let sortedTargetInfos = @@ -4875,27 +4860,26 @@ and GenDecisionTreesAndQueueTargets cenv cgbuf (queue: Queue<_>) targetInfos dec |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) |> List.ofSeq - GenPostponedAndQueueTargets cenv cgbuf queue sortedTargetInfos stackAtTargets sequel + GenPostponedDecisionTreeTargets cenv cgbuf sortedTargetInfos stackAtTargets sequel contf | (inplabOpt, eenv, tree) :: rest -> match tree with | TDSuccess(es, targetIdx) -> let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel match genTargetInfoOpt with - | Some _ -> - queue.Enqueue(fun () -> GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos rest stackAtTargets targets repeatSP sequel) - genTargetInfoOpt + | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> + GenDecisionTreesAndTargets cenv cgbuf targetInfos rest stackAtTargets targets repeatSP sequel contf + ) | _ -> - GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos rest stackAtTargets targets repeatSP sequel + GenDecisionTreesAndTargets cenv cgbuf targetInfos rest stackAtTargets targets repeatSP sequel contf | _ -> let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel - GenDecisionTreesAndQueueTargets cenv cgbuf queue targetInfos (newDecisions @ rest) stackAtTargets targets repeatSP sequel + GenDecisionTreesAndTargets cenv cgbuf targetInfos (newDecisions @ rest) stackAtTargets targets repeatSP sequel contf // Accumulate the decision graph as we go -and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel : (Queue (IlxGenEnv * EmitSequencePointState * Expr * sequel) option>) = - let queue = Queue() - queue.Enqueue (fun () -> GenDecisionTreesAndQueueTargets cenv cgbuf queue (IntMap.empty()) [(None, eenv, tree)] stackAtTargets targets repeatSP sequel) - queue +and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel contf = + GenDecisionTreesAndTargets cenv cgbuf (IntMap.empty()) [(None, eenv, tree)] stackAtTargets targets repeatSP sequel contf and TryFindTargetInfo targetInfos n = match IntMap.tryFind n targetInfos with From b663ffcec6566f053211309b3c5e4077f38dfa7f Mon Sep 17 00:00:00 2001 From: TIHan Date: Thu, 31 Oct 2019 20:09:02 -0700 Subject: [PATCH 33/68] Minor cleanup --- src/fsharp/IlxGen.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index 4b519e6f3c8..fdf44935022 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4840,7 +4840,7 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = // go to the join point Br afterJoin, afterJoin, stackAfterJoin, sequel -and GenPostponedDecisionTreeTargets cenv cgbuf targetInfos stackAtTargets sequel (contf: FakeUnit -> FakeUnit) : FakeUnit = +and GenPostponedDecisionTreeTargets cenv cgbuf targetInfos stackAtTargets sequel contf = match targetInfos with | [] -> contf Fake | (KeyValue(_, (targetInfo, isTargetPostponed))) :: rest -> From b5a99960760edd57d03930554150d2465eb6111b Mon Sep 17 00:00:00 2001 From: Will Smith Date: Fri, 1 Nov 2019 01:38:12 -0700 Subject: [PATCH 34/68] Pure CPS --- src/fsharp/IlxGen.fs | 98 ++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/src/fsharp/IlxGen.fs b/src/fsharp/IlxGen.fs index fdf44935022..3ba2296e81c 100644 --- a/src/fsharp/IlxGen.fs +++ b/src/fsharp/IlxGen.fs @@ -4840,6 +4840,16 @@ and GenJoinPoint cenv cgbuf pos eenv ty m sequel = // go to the join point Br afterJoin, afterJoin, stackAfterJoin, sequel +// Accumulate the decision graph as we go +and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel contf = + GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv tree targets repeatSP (IntMap.empty()) sequel (fun targetInfos -> + let sortedTargetInfos = + targetInfos + |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) + |> List.ofSeq + GenPostponedDecisionTreeTargets cenv cgbuf sortedTargetInfos stackAtTargets sequel contf + ) + and GenPostponedDecisionTreeTargets cenv cgbuf targetInfos stackAtTargets sequel contf = match targetInfos with | [] -> contf Fake @@ -4852,35 +4862,6 @@ and GenPostponedDecisionTreeTargets cenv cgbuf targetInfos stackAtTargets sequel else GenPostponedDecisionTreeTargets cenv cgbuf rest stackAtTargets sequel contf -and GenDecisionTreesAndTargets cenv cgbuf targetInfos decisions stackAtTargets targets repeatSP sequel contf = - match decisions with - | [] -> - let sortedTargetInfos = - targetInfos - |> Seq.sortBy (fun (KeyValue(targetIdx, _)) -> targetIdx) - |> List.ofSeq - - GenPostponedDecisionTreeTargets cenv cgbuf sortedTargetInfos stackAtTargets sequel contf - - | (inplabOpt, eenv, tree) :: rest -> - match tree with - | TDSuccess(es, targetIdx) -> - let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel - match genTargetInfoOpt with - | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> - GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> - GenDecisionTreesAndTargets cenv cgbuf targetInfos rest stackAtTargets targets repeatSP sequel contf - ) - | _ -> - GenDecisionTreesAndTargets cenv cgbuf targetInfos rest stackAtTargets targets repeatSP sequel contf - | _ -> - let newDecisions = GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel - GenDecisionTreesAndTargets cenv cgbuf targetInfos (newDecisions @ rest) stackAtTargets targets repeatSP sequel contf - -// Accumulate the decision graph as we go -and GenDecisionTreeAndTargets cenv cgbuf stackAtTargets eenv tree targets repeatSP sequel contf = - GenDecisionTreesAndTargets cenv cgbuf (IntMap.empty()) [(None, eenv, tree)] stackAtTargets targets repeatSP sequel contf - and TryFindTargetInfo targetInfos n = match IntMap.tryFind n targetInfos with | Some (targetInfo, _) -> Some targetInfo @@ -4890,7 +4871,7 @@ and TryFindTargetInfo targetInfos n = /// /// When inplabOpt is "Some inplab", we are assuming an existing branch to "inplab" and can optionally /// set inplab to point to another location if no codegen is required. -and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel = +and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree targets repeatSP targetInfos sequel (contf: Zmap<_,_> -> FakeUnit) = CG.SetStack cgbuf stackAtTargets // Set the expected initial stack. match tree with | TDBind(bind, rest) -> @@ -4903,13 +4884,18 @@ and GenDecisionTreeAndTargetsInner cenv cgbuf inplabOpt stackAtTargets eenv tree // we effectively lose an EndLocalScope for all dtrees that go to the same target // So we just pretend that the variable goes out of scope here. CG.SetMarkToHere cgbuf endScope - GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv rest targets repeatSP targetInfos sequel + GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv rest targets repeatSP targetInfos sequel contf - | TDSuccess _ -> - [(inplabOpt, eenv, tree)] + | TDSuccess(es, targetIdx) -> + let targetInfos, genTargetInfoOpt = GenDecisionTreeSuccess cenv cgbuf inplabOpt stackAtTargets eenv es targetIdx targets repeatSP targetInfos sequel + match genTargetInfoOpt with + | Some (eenvAtTarget, spExprAtTarget, exprAtTarget, sequelAtTarget) -> + GenLinearExpr cenv cgbuf eenvAtTarget spExprAtTarget exprAtTarget sequelAtTarget true (fun Fake -> contf targetInfos) + | _ -> + contf targetInfos | TDSwitch(e, cases, dflt, m) -> - GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases dflt m targets repeatSP sequel + GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases dflt m targets repeatSP targetInfos sequel contf and GetTarget (targets:_[]) n = if n >= targets.Length then failwith "GetTarget: target not found in decision tree" @@ -4983,7 +4969,7 @@ and GenDecisionTreeTarget cenv cgbuf stackAtTargets (targetMarkBeforeBinds, targ CG.SetStack cgbuf stackAtTargets (eenvAtTarget, spExpr, successExpr, (EndLocalScope(sequel, endScope))) -and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP sequel = +and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defaultTargetOpt switchm targets repeatSP targetInfos sequel contf = let g = cenv.g let m = e.Range match inplabOpt with None -> () | Some inplab -> CG.SetMarkToHere cgbuf inplab @@ -4993,7 +4979,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau // optimize a test against a boolean value, i.e. the all-important if-then-else | TCase(DecisionTreeTest.Const(Const.Bool b), successTree) :: _ -> let failureTree = (match defaultTargetOpt with None -> cases.Tail.Head.CaseTree | Some d -> d) - GenDecisionTreeTest cenv eenv.cloc cgbuf e None eenv (if b then successTree else failureTree) (if b then failureTree else successTree) targets sequel + GenDecisionTreeTest cenv eenv.cloc cgbuf stackAtTargets e None eenv (if b then successTree else failureTree) (if b then failureTree else successTree) targets repeatSP targetInfos sequel contf // // Remove a single test for a union case . Union case tests are always exa //| [ TCase(DecisionTreeTest.UnionCase _, successTree) ] when (defaultTargetOpt.IsNone) -> @@ -5010,7 +4996,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau let cuspec = GenUnionSpec cenv.amap m eenv.tyenv c.TyconRef tyargs let idx = c.Index let avoidHelpers = entityRefInThisAssembly g.compilingFslib c.TyconRef - GenDecisionTreeTest cenv eenv.cloc cgbuf e (Some (pop 1, Push [g.ilg.typ_Bool], Choice1Of2 (avoidHelpers, cuspec, idx))) eenv successTree failureTree targets sequel + GenDecisionTreeTest cenv eenv.cloc cgbuf stackAtTargets e (Some (pop 1, Push [g.ilg.typ_Bool], Choice1Of2 (avoidHelpers, cuspec, idx))) eenv successTree failureTree targets repeatSP targetInfos sequel contf | _ -> let caseLabels = List.map (fun _ -> CG.GenerateDelayMark cgbuf "switch_case") cases @@ -5041,7 +5027,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau BI_brtrue | _ -> failwith "internal error: GenDecisionTreeSwitch" CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (bi, (List.head caseLabels).CodeLabel)) - GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases + GenDecisionTreeCases cenv cgbuf stackAtTargets eenv defaultTargetOpt targets repeatSP targetInfos sequel caseLabels cases contf | DecisionTreeTest.ActivePatternCase _ -> error(InternalError("internal error in codegen: DecisionTreeTest.ActivePatternCase", switchm)) | DecisionTreeTest.UnionCase (hdc, tyargs) -> @@ -5057,7 +5043,7 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau let avoidHelpers = entityRefInThisAssembly g.compilingFslib hdc.TyconRef EraseUnions.emitDataSwitch g.ilg (UnionCodeGen cgbuf) (avoidHelpers, cuspec, dests) CG.EmitInstrs cgbuf (pop 1) Push0 [ ] // push/pop to match the line above - GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases + GenDecisionTreeCases cenv cgbuf stackAtTargets eenv defaultTargetOpt targets repeatSP targetInfos sequel caseLabels cases contf | DecisionTreeTest.Const c -> GenExpr cenv cgbuf eenv SPSuppress e Continue @@ -5100,25 +5086,30 @@ and GenDecisionTreeSwitch cenv cgbuf inplabOpt stackAtTargets eenv e cases defau CG.EmitInstr cgbuf (pop 1) Push0 (I_switch destinationLabels) else error(InternalError("non-dense integer matches not implemented in codegen - these should have been removed by the pattern match compiler", switchm)) - GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases + GenDecisionTreeCases cenv cgbuf stackAtTargets eenv defaultTargetOpt targets repeatSP targetInfos sequel caseLabels cases contf | _ -> error(InternalError("these matches should never be needed", switchm)) -and GenDecisionTreeCases cgbuf stackAtTargets eenv defaultTargetOpt caseLabels cases = +and GenDecisionTreeCases cenv cgbuf stackAtTargets eenv defaultTargetOpt targets repeatSP targetInfos sequel caseLabels cases (contf: Zmap<_,_> -> FakeUnit) = assert(cgbuf.GetCurrentStack() = stackAtTargets) // cgbuf stack should be unchanged over tests. [bug://1750]. - let defaultDecisions = - match defaultTargetOpt with - | Some defaultTarget -> [(None, eenv, defaultTarget)] - | None -> [] - - (caseLabels, cases) - ||> List.map2 (fun caseLabel (TCase(_, caseTree)) -> (Some caseLabel, eenv, caseTree)) - |> List.append defaultDecisions + match defaultTargetOpt with + | Some defaultTarget -> + GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv defaultTarget targets repeatSP targetInfos sequel (fun targetInfos -> + GenDecisionTreeCases cenv cgbuf stackAtTargets eenv None targets repeatSP targetInfos sequel caseLabels cases contf + ) + | None -> + match caseLabels, cases with + | caseLabel :: caseLabelsTail, (TCase(_, caseTree)) :: casesTail -> + GenDecisionTreeAndTargetsInner cenv cgbuf (Some caseLabel) stackAtTargets eenv caseTree targets repeatSP targetInfos sequel (fun targetInfos -> + GenDecisionTreeCases cenv cgbuf stackAtTargets eenv None targets repeatSP targetInfos sequel caseLabelsTail casesTail contf + ) + | _ -> + contf targetInfos // Used for the peephole optimization below and (|BoolExpr|_|) = function Expr.Const (Const.Bool b1, _, _) -> Some b1 | _ -> None -and GenDecisionTreeTest cenv cloc cgbuf e tester eenv successTree failureTree targets sequel = +and GenDecisionTreeTest cenv cloc cgbuf stackAtTargets e tester eenv successTree failureTree targets repeatSP targetInfos sequel contf = let g = cenv.g match successTree, failureTree with @@ -5145,7 +5136,7 @@ and GenDecisionTreeTest cenv cloc cgbuf e tester eenv successTree failureTree ta CG.EmitInstrs cgbuf (pop 0) (Push [g.ilg.typ_Bool]) [mkLdcInt32 0 ] CG.EmitInstrs cgbuf (pop 1) Push0 [AI_ceq] GenSequel cenv cloc cgbuf sequel - [] + contf targetInfos | _ -> failwith "internal error: GenDecisionTreeTest during bool elim" @@ -5167,8 +5158,9 @@ and GenDecisionTreeTest cenv cloc cgbuf e tester eenv successTree failureTree ta | Choice2Of2 i -> CG.EmitInstr cgbuf pops pushes i CG.EmitInstr cgbuf (pop 1) Push0 (I_brcmp (BI_brfalse, failure.CodeLabel)) - [ (None, eenv, successTree) - (Some failure, eenv, failureTree) ] + GenDecisionTreeAndTargetsInner cenv cgbuf None stackAtTargets eenv successTree targets repeatSP targetInfos sequel (fun targetInfos -> + GenDecisionTreeAndTargetsInner cenv cgbuf (Some failure) stackAtTargets eenv failureTree targets repeatSP targetInfos sequel contf + ) /// Generate fixups for letrec bindings and GenLetRecFixup cenv cgbuf eenv (ilxCloSpec: IlxClosureSpec, e, ilField: ILFieldSpec, e2, _m) = From 6d96c913573f93f88ac40bf821ce715b65d60653 Mon Sep 17 00:00:00 2001 From: TIHan Date: Fri, 1 Nov 2019 19:01:33 -0700 Subject: [PATCH 35/68] Use cache value if available early in a let binding. Stops from having to traverse entire expr. --- src/fsharp/TastOps.fs | 19 +++++++++++++------ src/fsharp/lib.fs | 4 ++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/fsharp/TastOps.fs b/src/fsharp/TastOps.fs index 5ea0d49b52d..94d0bcffaef 100644 --- a/src/fsharp/TastOps.fs +++ b/src/fsharp/TastOps.fs @@ -4388,6 +4388,10 @@ let bindLhs opts (bind: Binding) fvs = boundLocalVal opts bind.Var fvs let freeVarsCacheCompute opts cache f = if opts.canCache then cached cache f else f() +let tryGetFreeVarsCacheValue opts cache = + if opts.canCache then tryGetCacheValue cache + else ValueNone + let rec accBindRhs opts (TBind(_, repr, _)) acc = accFreeInExpr opts repr acc and accFreeInSwitchCases opts csl dflt (acc: FreeVars) = @@ -4485,13 +4489,16 @@ and accFreeInExpr (opts: FreeVarOptions) x acc = and accFreeInExprLinear (opts: FreeVarOptions) x acc contf = // for nested let-bindings, we need to continue after the whole let-binding is processed match x with - | Expr.Let (bind, e, _, cache) -> - let contf = contf << (fun free -> - unionFreeVars (freeVarsCacheCompute opts cache (fun () -> bindLhs opts bind (accBindRhs opts bind free))) acc ) - accFreeInExprLinear opts e emptyFreeVars contf + | Expr.Let (bind, e, _, cache) -> + match tryGetFreeVarsCacheValue opts cache with + | ValueSome free -> contf (unionFreeVars free acc) + | _ -> + accFreeInExprLinear opts e emptyFreeVars (contf << (fun free -> + unionFreeVars (freeVarsCacheCompute opts cache (fun () -> bindLhs opts bind (accBindRhs opts bind free))) acc + )) | _ -> - // No longer linear expr - accFreeInExpr opts x acc |> contf + // No longer linear expr + contf (accFreeInExpr opts x acc) and accFreeInExprNonLinear opts x acc = match x with diff --git a/src/fsharp/lib.fs b/src/fsharp/lib.fs index 8d5fa3f0afa..7ed3521ca37 100755 --- a/src/fsharp/lib.fs +++ b/src/fsharp/lib.fs @@ -394,6 +394,10 @@ let inline cacheOptRef cache f = cache := Some res res +let inline tryGetCacheValue cache = + match box cache.cacheVal with + | null -> ValueNone + | _ -> ValueSome cache.cacheVal #if DUMPER type Dumper(x:obj) = From e0209fec77cf93b6b5f8fc8d1904c41d19c8b40c Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2019 15:18:09 -0800 Subject: [PATCH 36/68] [master] Update dependencies from dotnet/arcade (#7706) * Update dependencies from https://github.com/dotnet/arcade build 20191004.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19504.2 * Update dependencies from https://github.com/dotnet/arcade build 20191005.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19505.1 * Update dependencies from https://github.com/dotnet/arcade build 20191006.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19506.1 * Update dependencies from https://github.com/dotnet/arcade build 20191009.5 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19509.5 * Update dependencies from https://github.com/dotnet/arcade build 20191010.4 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19510.4 * Update dependencies from https://github.com/dotnet/arcade build 20191011.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19511.1 * Update dependencies from https://github.com/dotnet/arcade build 20191015.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19515.1 * Update dependencies from https://github.com/dotnet/arcade build 20191015.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19515.2 * Update dependencies from https://github.com/dotnet/arcade build 20191017.8 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19517.8 * Update dependencies from https://github.com/dotnet/arcade build 20191018.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19518.2 * Update dependencies from https://github.com/dotnet/arcade build 20191021.4 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19521.4 * Update dependencies from https://github.com/dotnet/arcade build 20191022.8 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19522.8 * Update dependencies from https://github.com/dotnet/arcade build 20191023.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19523.3 * Update dependencies from https://github.com/dotnet/arcade build 20191024.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19524.2 * Update dependencies from https://github.com/dotnet/arcade build 20191025.2 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19525.2 * Update dependencies from https://github.com/dotnet/arcade build 20191026.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19526.1 * Update dependencies from https://github.com/dotnet/arcade build 20191027.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19527.3 * Update dependencies from https://github.com/dotnet/arcade build 20191028.5 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19528.5 * Update dependencies from https://github.com/dotnet/arcade build 20191029.9 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19529.9 * Update dependencies from https://github.com/dotnet/arcade build 20191030.15 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19530.15 * Update dependencies from https://github.com/dotnet/arcade build 20191031.14 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19531.14 * Update dependencies from https://github.com/dotnet/arcade build 20191101.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19551.3 * Update dependencies from https://github.com/dotnet/arcade build 20191102.1 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19552.1 * Update dependencies from https://github.com/dotnet/arcade build 20191104.3 - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19554.3 * work around dotnet/wpf#1718 by not embedding untracked sources * use arcade mechanism of populating package icons --- FSharpBuild.Directory.Build.props | 2 + eng/Version.Details.xml | 4 +- eng/common/PublishToSymbolServers.proj | 6 +- eng/common/SetupNugetSources.ps1 | 127 ++++++++++++++++ eng/common/SetupNugetSources.sh | 117 ++++++++++++++ eng/common/build.ps1 | 19 ++- eng/common/build.sh | 24 +-- eng/common/darc-init.ps1 | 9 +- eng/common/darc-init.sh | 24 ++- eng/common/dotnet-install.ps1 | 6 +- eng/common/dotnet-install.sh | 43 +++++- eng/common/post-build/post-build-utils.ps1 | 1 + eng/common/post-build/setup-maestro-vars.ps1 | 26 ---- eng/common/sdl/extract-artifact-packages.ps1 | 1 + eng/common/templates/job/job.yml | 2 +- ...ase.yml => netcore-3-tools-validation.yml} | 13 +- .../post-build/channels/netcore-3-tools.yml | 143 ++++++++++++++++++ .../post-build/channels/netcore-dev-31.yml | 17 ++- .../post-build/channels/netcore-dev-5.yml | 17 ++- .../channels/netcore-internal-30.yml | 6 +- .../channels/netcore-release-30.yml | 17 ++- .../channels/netcore-release-31.yml | 17 ++- .../channels/netcore-tools-latest.yml | 19 ++- .../channels/netcore-tools-validation.yml | 98 ++++++++++++ .../templates/post-build/common-variables.yml | 14 +- .../templates/post-build/post-build.yml | 21 ++- .../post-build/setup-maestro-vars.yml | 26 +++- eng/common/templates/steps/send-to-helix.yml | 3 + eng/common/tools.ps1 | 49 +++++- eng/common/tools.sh | 43 +++++- eng/targets/Settings.props | 5 + global.json | 2 +- .../FSharp.Core.nuget/icon.png => icon.png | Bin .../FSharp.Compiler.Private.Scripting.nuspec | 1 + .../Microsoft.FSharp.Compiler.nuspec | 1 + .../FSharp.Core.nuget.csproj | 4 - .../FSharp.Core.nuget/FSharp.Core.nuspec | 4 +- 37 files changed, 818 insertions(+), 113 deletions(-) create mode 100644 eng/common/SetupNugetSources.ps1 create mode 100644 eng/common/SetupNugetSources.sh delete mode 100644 eng/common/post-build/setup-maestro-vars.ps1 rename eng/common/templates/post-build/channels/{public-validation-release.yml => netcore-3-tools-validation.yml} (91%) create mode 100644 eng/common/templates/post-build/channels/netcore-3-tools.yml create mode 100644 eng/common/templates/post-build/channels/netcore-tools-validation.yml rename src/fsharp/FSharp.Core.nuget/icon.png => icon.png (100%) diff --git a/FSharpBuild.Directory.Build.props b/FSharpBuild.Directory.Build.props index 95fa8fcd020..791850399b3 100644 --- a/FSharpBuild.Directory.Build.props +++ b/FSharpBuild.Directory.Build.props @@ -18,6 +18,8 @@ + $(MSBuildThisFileDirectory)icon.png + $(RestoreAdditionalProjectSources);$(ArtifactsPackagesDir) $(ArtifactsPackagesDir) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index f10ba74c201..4da62ac3d05 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - da75c6547c64a91eb8a9cecf8c503331c2cc394a + ec6a0344dd2b1237cd63b38281295ce1e4b71458 diff --git a/eng/common/PublishToSymbolServers.proj b/eng/common/PublishToSymbolServers.proj index 5d55e312b01..311e2bbe0f6 100644 --- a/eng/common/PublishToSymbolServers.proj +++ b/eng/common/PublishToSymbolServers.proj @@ -37,6 +37,8 @@ 3650 true + true + true false @@ -56,7 +58,7 @@ DryRun="false" ConvertPortablePdbsToWindowsPdbs="false" PdbConversionTreatAsWarning="" - Condition="$(PublishToSymbolServer)"/> + Condition="$(PublishToSymbolServer) and $(PublishToMSDL)"/> + false + + false diff --git a/global.json b/global.json index d506e565469..4fb829e0e03 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19502.11", + "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19554.3", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } diff --git a/src/fsharp/FSharp.Core.nuget/icon.png b/icon.png similarity index 100% rename from src/fsharp/FSharp.Core.nuget/icon.png rename to icon.png diff --git a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec index dac8f0c240e..fb54c7f3938 100644 --- a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec +++ b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharp.Compiler.Private.Scripting.nuspec @@ -10,6 +10,7 @@ + $CommonFileElements$ diff --git a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec index dd9293cd88c..9505cf61e55 100644 --- a/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec +++ b/src/fsharp/FSharp.Compiler.nuget/Microsoft.FSharp.Compiler.nuspec @@ -34,6 +34,7 @@ + $CommonFileElements$ git commit --> git push -Write-Host "git add ." -git add . -if ($LASTEXITCODE -ne 0) { - Write-Error "Git add failed with exit code $LASTEXITCODE." -} -Write-Host "git -c user.email=`"dn-bot@microsoft.com`" -c user.name=`"Dotnet Bot`" commit -m `"$PushReason for $Repository/$BranchName`"" -git -c user.email="dn-bot@microsoft.com" -c user.name="Dotnet Bot" commit -m "$PushReason for $Repository/$BranchName" -if ($LASTEXITCODE -ne 0) { - Write-Error "Git commit failed with exit code $LASTEXITCODE." -} -Write-Host "git push" -git push -if ($LASTEXITCODE -ne 0) { - Write-Error "Git push failed with exit code $LASTEXITCODE." -} + # We create the temp directory where we'll store the sdl-config repository + $sdlDir = Join-Path $env:TEMP 'sdl' + if (Test-Path $sdlDir) { + Remove-Item -Force -Recurse $sdlDir + } -# Return to the original directory -Pop-Location \ No newline at end of file + Write-Host "git clone https://dnceng:`$AzureDevOpsAccessToken@dev.azure.com/dnceng/internal/_git/sdl-tool-cfg $sdlDir" + git clone https://dnceng:$AzureDevOpsAccessToken@dev.azure.com/dnceng/internal/_git/sdl-tool-cfg $sdlDir + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Git clone failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + # We copy the .gdn folder from our local run into the git repository so it can be committed + $sdlRepositoryFolder = Join-Path (Join-Path (Join-Path $sdlDir $Repository) $BranchName) '.gdn' + if (Get-Command Robocopy) { + Robocopy /S $GdnFolder $sdlRepositoryFolder + } else { + rsync -r $GdnFolder $sdlRepositoryFolder + } + # cd to the sdl-config directory so we can run git there + Push-Location $sdlDir + # git add . --> git commit --> git push + Write-Host 'git add .' + git add . + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Git add failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + Write-Host "git -c user.email=`"dn-bot@microsoft.com`" -c user.name=`"Dotnet Bot`" commit -m `"$PushReason for $Repository/$BranchName`"" + git -c user.email="dn-bot@microsoft.com" -c user.name="Dotnet Bot" commit -m "$PushReason for $Repository/$BranchName" + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Git commit failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + Write-Host 'git push' + git push + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Git push failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + + # Return to the original directory + Pop-Location +} +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} \ No newline at end of file diff --git a/eng/common/sdl/run-sdl.ps1 b/eng/common/sdl/run-sdl.ps1 index 9bc25314ae2..40a084f7969 100644 --- a/eng/common/sdl/run-sdl.ps1 +++ b/eng/common/sdl/run-sdl.ps1 @@ -5,55 +5,65 @@ Param( [string] $GdnFolder, [string[]] $ToolsList, [string] $UpdateBaseline, - [string] $GuardianLoggerLevel="Standard", + [string] $GuardianLoggerLevel='Standard', [string[]] $CrScanAdditionalRunConfigParams, [string[]] $PoliCheckAdditionalRunConfigParams ) -$ErrorActionPreference = "Stop" +$ErrorActionPreference = 'Stop' Set-StrictMode -Version 2.0 +$disableConfigureToolsetImport = $true $LASTEXITCODE = 0 -# We store config files in the r directory of .gdn -Write-Host $ToolsList -$gdnConfigPath = Join-Path $GdnFolder "r" -$ValidPath = Test-Path $GuardianCliLocation +try { + . $PSScriptRoot\..\tools.ps1 -if ($ValidPath -eq $False) -{ - Write-Host "Invalid Guardian CLI Location." - exit 1 -} + # We store config files in the r directory of .gdn + Write-Host $ToolsList + $gdnConfigPath = Join-Path $GdnFolder 'r' + $ValidPath = Test-Path $GuardianCliLocation -$configParam = @("--config") - -foreach ($tool in $ToolsList) { - $gdnConfigFile = Join-Path $gdnConfigPath "$tool-configure.gdnconfig" - Write-Host $tool - # We have to manually configure tools that run on source to look at the source directory only - if ($tool -eq "credscan") { - Write-Host "$GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args `" TargetDirectory < $TargetDirectory `" `" OutputType < pre `" $(If ($CrScanAdditionalRunConfigParams) {$CrScanAdditionalRunConfigParams})" - & $GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args " TargetDirectory < $TargetDirectory " "OutputType < pre" $(If ($CrScanAdditionalRunConfigParams) {$CrScanAdditionalRunConfigParams}) - if ($LASTEXITCODE -ne 0) { - Write-Host "Guardian configure for $tool failed with exit code $LASTEXITCODE." - exit $LASTEXITCODE - } + if ($ValidPath -eq $False) + { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Invalid Guardian CLI Location." + ExitWithExitCode 1 } - if ($tool -eq "policheck") { - Write-Host "$GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args `" Target < $TargetDirectory `" $(If ($PoliCheckAdditionalRunConfigParams) {$PoliCheckAdditionalRunConfigParams})" - & $GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args " Target < $TargetDirectory " $(If ($PoliCheckAdditionalRunConfigParams) {$PoliCheckAdditionalRunConfigParams}) - if ($LASTEXITCODE -ne 0) { - Write-Host "Guardian configure for $tool failed with exit code $LASTEXITCODE." - exit $LASTEXITCODE + + $configParam = @('--config') + + foreach ($tool in $ToolsList) { + $gdnConfigFile = Join-Path $gdnConfigPath "$tool-configure.gdnconfig" + Write-Host $tool + # We have to manually configure tools that run on source to look at the source directory only + if ($tool -eq 'credscan') { + Write-Host "$GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args `" TargetDirectory < $TargetDirectory `" `" OutputType < pre `" $(If ($CrScanAdditionalRunConfigParams) {$CrScanAdditionalRunConfigParams})" + & $GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args " TargetDirectory < $TargetDirectory " "OutputType < pre" $(If ($CrScanAdditionalRunConfigParams) {$CrScanAdditionalRunConfigParams}) + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian configure for $tool failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } + } + if ($tool -eq 'policheck') { + Write-Host "$GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args `" Target < $TargetDirectory `" $(If ($PoliCheckAdditionalRunConfigParams) {$PoliCheckAdditionalRunConfigParams})" + & $GuardianCliLocation configure --working-directory $WorkingDirectory --tool $tool --output-path $gdnConfigFile --logger-level $GuardianLoggerLevel --noninteractive --force --args " Target < $TargetDirectory " $(If ($PoliCheckAdditionalRunConfigParams) {$PoliCheckAdditionalRunConfigParams}) + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian configure for $tool failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } } - } - $configParam+=$gdnConfigFile -} + $configParam+=$gdnConfigFile + } -Write-Host "$GuardianCliLocation run --working-directory $WorkingDirectory --baseline mainbaseline --update-baseline $UpdateBaseline --logger-level $GuardianLoggerLevel $configParam" -& $GuardianCliLocation run --working-directory $WorkingDirectory --tool $tool --baseline mainbaseline --update-baseline $UpdateBaseline --logger-level $GuardianLoggerLevel $configParam -if ($LASTEXITCODE -ne 0) { - Write-Host "Guardian run for $ToolsList using $configParam failed with exit code $LASTEXITCODE." - exit $LASTEXITCODE + Write-Host "$GuardianCliLocation run --working-directory $WorkingDirectory --baseline mainbaseline --update-baseline $UpdateBaseline --logger-level $GuardianLoggerLevel $configParam" + & $GuardianCliLocation run --working-directory $WorkingDirectory --tool $tool --baseline mainbaseline --update-baseline $UpdateBaseline --logger-level $GuardianLoggerLevel $configParam + if ($LASTEXITCODE -ne 0) { + Write-PipelineTelemetryError -Force -Category 'Sdl' -Message "Guardian run for $ToolsList using $configParam failed with exit code $LASTEXITCODE." + ExitWithExitCode $LASTEXITCODE + } } +catch { + Write-Host $_.ScriptStackTrace + Write-PipelineTelemetryError -Category 'Sdl' -Message $_ + ExitWithExitCode 1 +} \ No newline at end of file diff --git a/eng/common/templates/post-build/common-variables.yml b/eng/common/templates/post-build/common-variables.yml index 0a2c40c1035..9505cf170f0 100644 --- a/eng/common/templates/post-build/common-variables.yml +++ b/eng/common/templates/post-build/common-variables.yml @@ -4,7 +4,7 @@ variables: - group: DotNet-DotNetCli-Storage - group: DotNet-MSRC-Storage - group: Publish-Build-Assets - + # .NET Core 3.1 Dev - name: PublicDevRelease_31_Channel_Id value: 128 @@ -13,19 +13,19 @@ variables: - name: NetCore_5_Dev_Channel_Id value: 131 - # .NET Tools - Validation - - name: NetCore_Tools_Validation_Channel_Id + # .NET Eng - Validation + - name: Net_Eng_Validation_Channel_Id value: 9 - # .NET Tools - Latest - - name: NetCore_Tools_Latest_Channel_Id + # .NET Eng - Latest + - name: Net_Eng_Latest_Channel_Id value: 2 - # .NET 3 Tools - Validation - - name: NETCore_3_Tools_Validation_Channel_Id + # .NET 3 Eng - Validation + - name: NET_3_Eng_Validation_Channel_Id value: 390 - # .NET 3 Tools - Latest + # .NET 3 Eng - name: NetCore_3_Tools_Channel_Id value: 344 @@ -49,6 +49,10 @@ variables: - name: NetCore_31_Blazor_Features_Channel_Id value: 531 + # .NET Core Experimental + - name: NetCore_Experimental_Channel_Id + value: 562 + # Whether the build is internal or not - name: IsInternalBuild value: ${{ and(ne(variables['System.TeamProject'], 'public'), contains(variables['Build.SourceBranch'], 'internal')) }} diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index 5965cc2005d..8a8d84f2026 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -137,8 +137,8 @@ stages: dependsOn: ${{ parameters.publishDependsOn }} publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} - stageName: 'NetCore_Tools_Latest_Publish' - channelName: '.NET Tools - Latest' + stageName: 'Net_Eng_Latest_Publish' + channelName: '.NET Eng - Latest' channelId: 2 transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' @@ -150,8 +150,8 @@ stages: dependsOn: ${{ parameters.publishDependsOn }} publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} - stageName: 'PVR_Publish' - channelName: '.NET Tools - Validation' + stageName: 'Net_Eng_Validation_Publish' + channelName: '.NET Eng - Validation' channelId: 9 transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json' @@ -195,3 +195,29 @@ stages: transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json' shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json' symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-symbols/nuget/v3/index.json' + +- template: \eng\common\templates\post-build\channels\generic-internal-channel.yml + parameters: + artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} + dependsOn: ${{ parameters.publishDependsOn }} + publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} + symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} + stageName: 'NET_Internal_Tooling_Publishing' + channelName: '.NET Internal Tooling' + channelId: 551 + transportFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json' + shippingFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json' + symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal-symbols/nuget/v3/index.json' + +- template: \eng\common\templates\post-build\channels\generic-public-channel.yml + parameters: + artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }} + dependsOn: ${{ parameters.publishDependsOn }} + publishInstallersAndChecksums: ${{ parameters.publishInstallersAndChecksums }} + symbolPublishingAdditionalParameters: ${{ parameters.symbolPublishingAdditionalParameters }} + stageName: 'NETCore_Experimental_Publishing' + channelName: '.NET Core Experimental' + channelId: 562 + transportFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json' + shippingFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json' + symbolsFeed: 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental-symbols/nuget/v3/index.json' diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 42ca33ac33d..d762c9f044a 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -5,7 +5,7 @@ [bool]$ci = if (Test-Path variable:ci) { $ci } else { $false } # Build configuration. Common values include 'Debug' and 'Release', but the repository may use other names. -[string]$configuration = if (Test-Path variable:configuration) { $configuration } else { "Debug" } +[string]$configuration = if (Test-Path variable:configuration) { $configuration } else { 'Debug' } # Set to true to output binary log from msbuild. Note that emitting binary log slows down the build. # Binary log must be enabled on CI. @@ -24,7 +24,7 @@ [bool]$restore = if (Test-Path variable:restore) { $restore } else { $true } # Adjusts msbuild verbosity level. -[string]$verbosity = if (Test-Path variable:verbosity) { $verbosity } else { "minimal" } +[string]$verbosity = if (Test-Path variable:verbosity) { $verbosity } else { 'minimal' } # Set to true to reuse msbuild nodes. Recommended to not reuse on CI. [bool]$nodeReuse = if (Test-Path variable:nodeReuse) { $nodeReuse } else { !$ci } @@ -41,23 +41,23 @@ # Enable repos to use a particular version of the on-line dotnet-install scripts. # default URL: https://dot.net/v1/dotnet-install.ps1 -[string]$dotnetInstallScriptVersion = if (Test-Path variable:dotnetInstallScriptVersion) { $dotnetInstallScriptVersion } else { "v1" } +[string]$dotnetInstallScriptVersion = if (Test-Path variable:dotnetInstallScriptVersion) { $dotnetInstallScriptVersion } else { 'v1' } # True to use global NuGet cache instead of restoring packages to repository-local directory. [bool]$useGlobalNuGetCache = if (Test-Path variable:useGlobalNuGetCache) { $useGlobalNuGetCache } else { !$ci } # An array of names of processes to stop on script exit if prepareMachine is true. -$processesToStopOnExit = if (Test-Path variable:processesToStopOnExit) { $processesToStopOnExit } else { @("msbuild", "dotnet", "vbcscompiler") } +$processesToStopOnExit = if (Test-Path variable:processesToStopOnExit) { $processesToStopOnExit } else { @('msbuild', 'dotnet', 'vbcscompiler') } $disableConfigureToolsetImport = if (Test-Path variable:disableConfigureToolsetImport) { $disableConfigureToolsetImport } else { $null } set-strictmode -version 2.0 -$ErrorActionPreference = "Stop" +$ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 function Create-Directory([string[]] $path) { if (!(Test-Path $path)) { - New-Item -path $path -force -itemType "Directory" | Out-Null + New-Item -path $path -force -itemType 'Directory' | Out-Null } } @@ -121,7 +121,7 @@ function InitializeDotNetCli([bool]$install) { # Find the first path on %PATH% that contains the dotnet.exe if ($useInstalledDotNetCli -and (-not $globalJsonHasRuntimes) -and ($env:DOTNET_INSTALL_DIR -eq $null)) { - $dotnetCmd = Get-Command "dotnet.exe" -ErrorAction SilentlyContinue + $dotnetCmd = Get-Command 'dotnet.exe' -ErrorAction SilentlyContinue if ($dotnetCmd -ne $null) { $env:DOTNET_INSTALL_DIR = Split-Path $dotnetCmd.Path -Parent } @@ -134,13 +134,13 @@ function InitializeDotNetCli([bool]$install) { if ((-not $globalJsonHasRuntimes) -and ($env:DOTNET_INSTALL_DIR -ne $null) -and (Test-Path(Join-Path $env:DOTNET_INSTALL_DIR "sdk\$dotnetSdkVersion"))) { $dotnetRoot = $env:DOTNET_INSTALL_DIR } else { - $dotnetRoot = Join-Path $RepoRoot ".dotnet" + $dotnetRoot = Join-Path $RepoRoot '.dotnet' if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) { if ($install) { InstallDotNetSdk $dotnetRoot $dotnetSdkVersion } else { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Unable to find dotnet with SDK version '$dotnetSdkVersion'" + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unable to find dotnet with SDK version '$dotnetSdkVersion'" ExitWithExitCode 1 } } @@ -163,7 +163,7 @@ function InitializeDotNetCli([bool]$install) { } function GetDotNetInstallScript([string] $dotnetRoot) { - $installScript = Join-Path $dotnetRoot "dotnet-install.ps1" + $installScript = Join-Path $dotnetRoot 'dotnet-install.ps1' if (!(Test-Path $installScript)) { Create-Directory $dotnetRoot $ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit @@ -173,17 +173,17 @@ function GetDotNetInstallScript([string] $dotnetRoot) { return $installScript } -function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $architecture = "") { +function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $architecture = '') { InstallDotNet $dotnetRoot $version $architecture } function InstallDotNet([string] $dotnetRoot, [string] $version, - [string] $architecture = "", - [string] $runtime = "", + [string] $architecture = '', + [string] $runtime = '', [bool] $skipNonVersionedFiles = $false, - [string] $runtimeSourceFeed = "", - [string] $runtimeSourceFeedKey = "") { + [string] $runtimeSourceFeed = '', + [string] $runtimeSourceFeedKey = '') { $installScript = GetDotNetInstallScript $dotnetRoot $installParameters = @{ @@ -199,7 +199,7 @@ function InstallDotNet([string] $dotnetRoot, & $installScript @installParameters } catch { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Failed to install dotnet runtime '$runtime' from public location." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Failed to install dotnet runtime '$runtime' from public location." # Only the runtime can be installed from a custom [private] location. if ($runtime -and ($runtimeSourceFeed -or $runtimeSourceFeedKey)) { @@ -215,7 +215,7 @@ function InstallDotNet([string] $dotnetRoot, & $installScript @installParameters } catch { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Failed to install dotnet runtime '$runtime' from custom location '$runtimeSourceFeed'." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Failed to install dotnet runtime '$runtime' from custom location '$runtimeSourceFeed'." } } } @@ -238,16 +238,16 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = } if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } - $vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { "15.9" } + $vsMinVersionStr = if ($vsRequirements.version) { $vsRequirements.version } else { '15.9' } $vsMinVersion = [Version]::new($vsMinVersionStr) # Try msbuild command available in the environment. if ($env:VSINSTALLDIR -ne $null) { - $msbuildCmd = Get-Command "msbuild.exe" -ErrorAction SilentlyContinue + $msbuildCmd = Get-Command 'msbuild.exe' -ErrorAction SilentlyContinue if ($msbuildCmd -ne $null) { # Workaround for https://github.com/dotnet/roslyn/issues/35793 # Due to this issue $msbuildCmd.Version returns 0.0.0.0 for msbuild.exe 16.2+ - $msbuildVersion = [Version]::new((Get-Item $msbuildCmd.Path).VersionInfo.ProductVersion.Split(@('-', '+'))[0]) + $msbuildVersion = [Version]::new((Get-Item $msbuildCmd.Path).VersionInfo.ProductVersion.Split([char[]]@('-', '+'))[0]) if ($msbuildVersion -ge $vsMinVersion) { return $global:_MSBuildExe = $msbuildCmd.Path @@ -267,7 +267,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = InitializeVisualStudioEnvironmentVariables $vsInstallDir $vsMajorVersion } else { - if (Get-Member -InputObject $GlobalJson.tools -Name "xcopy-msbuild") { + if (Get-Member -InputObject $GlobalJson.tools -Name 'xcopy-msbuild') { $xcopyMSBuildVersion = $GlobalJson.tools.'xcopy-msbuild' $vsMajorVersion = $xcopyMSBuildVersion.Split('.')[0] } else { @@ -277,7 +277,7 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements = $vsInstallDir = InitializeXCopyMSBuild $xcopyMSBuildVersion $install if ($vsInstallDir -eq $null) { - throw "Unable to find Visual Studio that has required version and components installed" + throw 'Unable to find Visual Studio that has required version and components installed' } } @@ -301,7 +301,7 @@ function InstallXCopyMSBuild([string]$packageVersion) { } function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { - $packageName = "RoslynTools.MSBuild" + $packageName = 'RoslynTools.MSBuild' $packageDir = Join-Path $ToolsDir "msbuild\$packageVersion" $packagePath = Join-Path $packageDir "$packageName.$packageVersion.nupkg" @@ -317,7 +317,7 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { Unzip $packagePath $packageDir } - return Join-Path $packageDir "tools" + return Join-Path $packageDir 'tools' } # @@ -334,32 +334,32 @@ function InitializeXCopyMSBuild([string]$packageVersion, [bool]$install) { # or $null if no instance meeting the requirements is found on the machine. # function LocateVisualStudio([object]$vsRequirements = $null){ - if (Get-Member -InputObject $GlobalJson.tools -Name "vswhere") { + if (Get-Member -InputObject $GlobalJson.tools -Name 'vswhere') { $vswhereVersion = $GlobalJson.tools.vswhere } else { - $vswhereVersion = "2.5.2" + $vswhereVersion = '2.5.2' } $vsWhereDir = Join-Path $ToolsDir "vswhere\$vswhereVersion" - $vsWhereExe = Join-Path $vsWhereDir "vswhere.exe" + $vsWhereExe = Join-Path $vsWhereDir 'vswhere.exe' if (!(Test-Path $vsWhereExe)) { Create-Directory $vsWhereDir - Write-Host "Downloading vswhere" + Write-Host 'Downloading vswhere' Invoke-WebRequest "https://github.com/Microsoft/vswhere/releases/download/$vswhereVersion/vswhere.exe" -OutFile $vswhereExe } if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs } - $args = @("-latest", "-prerelease", "-format", "json", "-requires", "Microsoft.Component.MSBuild", "-products", "*") + $args = @('-latest', '-prerelease', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*') - if (Get-Member -InputObject $vsRequirements -Name "version") { - $args += "-version" + if (Get-Member -InputObject $vsRequirements -Name 'version') { + $args += '-version' $args += $vsRequirements.version } - if (Get-Member -InputObject $vsRequirements -Name "components") { + if (Get-Member -InputObject $vsRequirements -Name 'components') { foreach ($component in $vsRequirements.components) { - $args += "-requires" + $args += '-requires' $args += $component } } @@ -385,27 +385,27 @@ function InitializeBuildTool() { # Initialize dotnet cli if listed in 'tools' $dotnetRoot = $null - if (Get-Member -InputObject $GlobalJson.tools -Name "dotnet") { + if (Get-Member -InputObject $GlobalJson.tools -Name 'dotnet') { $dotnetRoot = InitializeDotNetCli -install:$restore } - if ($msbuildEngine -eq "dotnet") { + if ($msbuildEngine -eq 'dotnet') { if (!$dotnetRoot) { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "/global.json must specify 'tools.dotnet'." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "/global.json must specify 'tools.dotnet'." ExitWithExitCode 1 } - $buildTool = @{ Path = Join-Path $dotnetRoot "dotnet.exe"; Command = "msbuild"; Tool = "dotnet"; Framework = "netcoreapp2.1" } + $buildTool = @{ Path = Join-Path $dotnetRoot 'dotnet.exe'; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'netcoreapp2.1' } } elseif ($msbuildEngine -eq "vs") { try { $msbuildPath = InitializeVisualStudioMSBuild -install:$restore } catch { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message $_ + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message $_ ExitWithExitCode 1 } $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472" } } else { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'." ExitWithExitCode 1 } @@ -414,15 +414,15 @@ function InitializeBuildTool() { function GetDefaultMSBuildEngine() { # Presence of tools.vs indicates the repo needs to build using VS msbuild on Windows. - if (Get-Member -InputObject $GlobalJson.tools -Name "vs") { - return "vs" + if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') { + return 'vs' } - if (Get-Member -InputObject $GlobalJson.tools -Name "dotnet") { - return "dotnet" + if (Get-Member -InputObject $GlobalJson.tools -Name 'dotnet') { + return 'dotnet' } - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "-msbuildEngine must be specified, or /global.json must specify 'tools.dotnet' or 'tools.vs'." ExitWithExitCode 1 } @@ -431,9 +431,9 @@ function GetNuGetPackageCachePath() { # Use local cache on CI to ensure deterministic build, # use global cache in dev builds to avoid cost of downloading packages. if ($useGlobalNuGetCache) { - $env:NUGET_PACKAGES = Join-Path $env:UserProfile ".nuget\packages" + $env:NUGET_PACKAGES = Join-Path $env:UserProfile '.nuget\packages' } else { - $env:NUGET_PACKAGES = Join-Path $RepoRoot ".packages" + $env:NUGET_PACKAGES = Join-Path $RepoRoot '.packages' } } @@ -475,14 +475,14 @@ function InitializeToolset() { } if (-not $restore) { - Write-PipelineTelemetryError -Category "InitializeToolset" -Message "Toolset version $toolsetVersion has not been restored." + Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Toolset version $toolsetVersion has not been restored." ExitWithExitCode 1 } $buildTool = InitializeBuildTool - $proj = Join-Path $ToolsetDir "restore.proj" - $bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "ToolsetRestore.binlog") } else { "" } + $proj = Join-Path $ToolsetDir 'restore.proj' + $bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'ToolsetRestore.binlog') } else { '' } '' | Set-Content $proj @@ -504,7 +504,7 @@ function ExitWithExitCode([int] $exitCode) { } function Stop-Processes() { - Write-Host "Killing running build processes..." + Write-Host 'Killing running build processes...' foreach ($processName in $processesToStopOnExit) { Get-Process -Name $processName -ErrorAction SilentlyContinue | Stop-Process } @@ -521,7 +521,7 @@ function MSBuild() { # Work around issues with Azure Artifacts credential provider # https://github.com/dotnet/arcade/issues/3932 - if ($ci -and $buildTool.Tool -eq "dotnet") { + if ($ci -and $buildTool.Tool -eq 'dotnet') { dotnet nuget locals http-cache -c $env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS = 20 @@ -532,7 +532,7 @@ function MSBuild() { $toolsetBuildProject = InitializeToolset $path = Split-Path -parent $toolsetBuildProject - $path = Join-Path $path (Join-Path $buildTool.Framework "Microsoft.DotNet.Arcade.Sdk.dll") + $path = Join-Path $path (Join-Path $buildTool.Framework 'Microsoft.DotNet.Arcade.Sdk.dll') $args += "/logger:$path" } @@ -547,12 +547,12 @@ function MSBuild() { function MSBuild-Core() { if ($ci) { if (!$binaryLog) { - Write-PipelineTaskError -Message "Binary log must be enabled in CI build." + Write-PipelineTelemetryError -Category 'Build' -Message 'Binary log must be enabled in CI build.' ExitWithExitCode 1 } if ($nodeReuse) { - Write-PipelineTaskError -Message "Node reuse must be disabled in CI build." + Write-PipelineTelemetryError -Category 'Build' -Message 'Node reuse must be disabled in CI build.' ExitWithExitCode 1 } } @@ -562,10 +562,10 @@ function MSBuild-Core() { $cmdArgs = "$($buildTool.Command) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci" if ($warnAsError) { - $cmdArgs += " /warnaserror /p:TreatWarningsAsErrors=true" + $cmdArgs += ' /warnaserror /p:TreatWarningsAsErrors=true' } else { - $cmdArgs += " /p:TreatWarningsAsErrors=false" + $cmdArgs += ' /p:TreatWarningsAsErrors=false' } foreach ($arg in $args) { @@ -577,7 +577,7 @@ function MSBuild-Core() { $exitCode = Exec-Process $buildTool.Path $cmdArgs if ($exitCode -ne 0) { - Write-PipelineTaskError -Message "Build failed." + Write-PipelineTelemetryError Category 'Build' -Message 'Build failed.' $buildLog = GetMSBuildBinaryLogCommandLineArgument $args if ($buildLog -ne $null) { @@ -592,12 +592,12 @@ function GetMSBuildBinaryLogCommandLineArgument($arguments) { foreach ($argument in $arguments) { if ($argument -ne $null) { $arg = $argument.Trim() - if ($arg.StartsWith("/bl:", "OrdinalIgnoreCase")) { - return $arg.Substring("/bl:".Length) + if ($arg.StartsWith('/bl:', "OrdinalIgnoreCase")) { + return $arg.Substring('/bl:'.Length) } - if ($arg.StartsWith("/binaryLogger:", "OrdinalIgnoreCase")) { - return $arg.Substring("/binaryLogger:".Length) + if ($arg.StartsWith('/binaryLogger:', 'OrdinalIgnoreCase')) { + return $arg.Substring('/binaryLogger:'.Length) } } } @@ -607,14 +607,14 @@ function GetMSBuildBinaryLogCommandLineArgument($arguments) { . $PSScriptRoot\pipeline-logging-functions.ps1 -$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot "..\..") -$EngRoot = Resolve-Path (Join-Path $PSScriptRoot "..") -$ArtifactsDir = Join-Path $RepoRoot "artifacts" -$ToolsetDir = Join-Path $ArtifactsDir "toolset" -$ToolsDir = Join-Path $RepoRoot ".tools" -$LogDir = Join-Path (Join-Path $ArtifactsDir "log") $configuration -$TempDir = Join-Path (Join-Path $ArtifactsDir "tmp") $configuration -$GlobalJson = Get-Content -Raw -Path (Join-Path $RepoRoot "global.json") | ConvertFrom-Json +$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..\..') +$EngRoot = Resolve-Path (Join-Path $PSScriptRoot '..') +$ArtifactsDir = Join-Path $RepoRoot 'artifacts' +$ToolsetDir = Join-Path $ArtifactsDir 'toolset' +$ToolsDir = Join-Path $RepoRoot '.tools' +$LogDir = Join-Path (Join-Path $ArtifactsDir 'log') $configuration +$TempDir = Join-Path (Join-Path $ArtifactsDir 'tmp') $configuration +$GlobalJson = Get-Content -Raw -Path (Join-Path $RepoRoot 'global.json') | ConvertFrom-Json # true if global.json contains a "runtimes" section $globalJsonHasRuntimes = if ($GlobalJson.tools.PSObject.Properties.Name -Match 'runtimes') { $true } else { $false } @@ -631,8 +631,14 @@ Write-PipelineSetVariable -Name 'TMP' -Value $TempDir # Import custom tools configuration, if present in the repo. # Note: Import in global scope so that the script set top-level variables without qualification. if (!$disableConfigureToolsetImport) { - $configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1" + $configureToolsetScript = Join-Path $EngRoot 'configure-toolset.ps1' if (Test-Path $configureToolsetScript) { - . $configureToolsetScript + . $configureToolsetScript + if ((Test-Path variable:failOnConfigureToolsetError) -And $failOnConfigureToolsetError) { + if ((Test-Path variable:LastExitCode) -And ($LastExitCode -ne 0)) { + Write-PipelineTelemetryError -Category 'Build' -Message 'configure-toolset.ps1 returned a non-zero exit code' + ExitWithExitCode $LastExitCode + } + } } } diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 6a23ac0a345..f58db5e25d1 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -4,7 +4,6 @@ # CI mode - set to true on CI server for PR validation build or official build. ci=${ci:-false} -disable_configure_toolset_import=${disable_configure_toolset_import:-} # Set to true to use the pipelines logger which will enable Azure logging output. # https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md @@ -82,7 +81,7 @@ function ReadGlobalVersion { local pattern="\"$key\" *: *\"(.*)\"" if [[ ! $line =~ $pattern ]]; then - Write-PipelineTelemetryError -category 'InitializeToolset' "Error: Cannot find \"$key\" in $global_json_file" + Write-PipelineTelemetryError -category 'Build' "Error: Cannot find \"$key\" in $global_json_file" ExitWithExitCode 1 fi @@ -325,7 +324,7 @@ function InitializeToolset { local toolset_build_proj=`cat "$toolset_location_file"` if [[ ! -a "$toolset_build_proj" ]]; then - Write-PipelineTelemetryError -category 'InitializeToolset' "Invalid toolset path: $toolset_build_proj" + Write-PipelineTelemetryError -category 'Build' "Invalid toolset path: $toolset_build_proj" ExitWithExitCode 3 fi @@ -375,12 +374,12 @@ function MSBuild { function MSBuild-Core { if [[ "$ci" == true ]]; then if [[ "$binary_log" != true ]]; then - Write-PipelineTaskError "Binary log must be enabled in CI build." + Write-PipelineTelemetryError -category 'Build' "Binary log must be enabled in CI build." ExitWithExitCode 1 fi if [[ "$node_reuse" == true ]]; then - Write-PipelineTaskError "Node reuse must be disabled in CI build." + Write-PipelineTelemetryError -category 'Build' "Node reuse must be disabled in CI build." ExitWithExitCode 1 fi fi @@ -394,7 +393,7 @@ function MSBuild-Core { "$_InitializeBuildTool" "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@" || { local exit_code=$? - Write-PipelineTaskError "Build failed (exit code '$exit_code')." + Write-PipelineTelemetryError -category 'Build' "Build failed (exit code '$exit_code')." ExitWithExitCode $exit_code } } @@ -437,7 +436,7 @@ Write-PipelineSetVariable -name "Temp" -value "$temp_dir" Write-PipelineSetVariable -name "TMP" -value "$temp_dir" # Import custom tools configuration, if present in the repo. -if [[ -z "$disable_configure_toolset_import" ]]; then +if [ -z "${disable_configure_toolset_import:-}" ]; then configure_toolset_script="$eng_root/configure-toolset.sh" if [[ -a "$configure_toolset_script" ]]; then . "$configure_toolset_script" diff --git a/global.json b/global.json index ca1b0780a72..e0109fb0fec 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19569.6", + "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19601.1", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From b757c165dcf28829f3431f3a678de1486b3b5db7 Mon Sep 17 00:00:00 2001 From: "dotnet-maestro[bot]" <42748379+dotnet-maestro[bot]@users.noreply.github.com> Date: Tue, 3 Dec 2019 10:26:57 -0800 Subject: [PATCH 67/68] Update dependencies from https://github.com/dotnet/arcade build 20191202.4 (#7923) - Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19602.4 --- eng/Version.Details.xml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 8bd6f3d7de3..0288911f9e9 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,9 +3,9 @@ - + https://github.com/dotnet/arcade - c0b56ff3569e3c7475070486c40543ea4c6f6dc7 + 9d34fd008e754e1ada35c8b6bc3694e7a90b4ed7 diff --git a/global.json b/global.json index e0109fb0fec..707f7b7357e 100644 --- a/global.json +++ b/global.json @@ -10,7 +10,7 @@ } }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19601.1", + "Microsoft.DotNet.Arcade.Sdk": "5.0.0-beta.19602.4", "Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2" } } From 4978145c8516351b1338262b6b9bdf2d0372e757 Mon Sep 17 00:00:00 2001 From: "Brett V. Forsgren" Date: Tue, 3 Dec 2019 14:40:00 -0800 Subject: [PATCH 68/68] fire event when a value is bound at the root of a script evaluation (#7919) * fire event when a value is bound at the root of a script evaluation * simplify event notifying bound values in interactive --- .../FSharpScript.fs | 2 + src/fsharp/fsi/fsi.fs | 11 ++++- src/fsharp/fsi/fsi.fsi | 3 ++ .../FSharpScriptTests.fs | 46 +++++++++++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs index 6380c203eda..3d9e113bcc5 100644 --- a/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs +++ b/src/fsharp/FSharp.Compiler.Private.Scripting/FSharpScript.fs @@ -38,6 +38,8 @@ type FSharpScript(?captureInput: bool, ?captureOutput: bool, ?additionalArgs: st member __.AssemblyReferenceAdded = fsi.AssemblyReferenceAdded + member __.ValueBound = fsi.ValueBound + member __.ProvideInput = stdin.ProvideInput member __.OutputProduced = outputProduced.Publish diff --git a/src/fsharp/fsi/fsi.fs b/src/fsharp/fsi/fsi.fs index 78b142bd516..c5e71384f1f 100644 --- a/src/fsharp/fsi/fsi.fs +++ b/src/fsharp/fsi/fsi.fs @@ -950,6 +950,7 @@ type internal FsiDynamicCompiler let assemblyName = "FSI-ASSEMBLY" let assemblyReferenceAddedEvent = Control.Event() + let valueBoundEvent = Control.Event<_>() let mutable fragmentId = 0 let mutable prevIt : ValRef option = None @@ -1155,6 +1156,10 @@ type internal FsiDynamicCompiler if v.CompiledName = "it" then itValue <- fsiValueOpt + match fsiValueOpt with + | Some fsiValue -> valueBoundEvent.Trigger(fsiValue.ReflectionValue, fsiValue.ReflectionType, v.CompiledName) + | None -> () + let symbol = FSharpSymbol.Create(cenv, v.Item) let symbolUse = FSharpSymbolUse(tcGlobals, newState.tcState.TcEnvFromImpls.DisplayEnv, symbol, ItemOccurence.Binding, v.DeclarationLocation) fsi.TriggerEvaluation (fsiValueOpt, symbolUse, decl) @@ -1331,6 +1336,8 @@ type internal FsiDynamicCompiler member __.AssemblyReferenceAdded = assemblyReferenceAddedEvent.Publish + member __.ValueBound = valueBoundEvent.Publish + //---------------------------------------------------------------------------- // ctrl-c handling //---------------------------------------------------------------------------- @@ -2222,7 +2229,6 @@ type internal FsiInteractionProcessor let fsiInteractiveChecker = FsiInteractiveChecker(legacyReferenceResolver, checker, tcConfig, istate.tcGlobals, istate.tcImports, istate.tcState) fsiInteractiveChecker.ParseAndCheckInteraction(ctok, SourceText.ofString text) - //---------------------------------------------------------------------------- // Server mode: //---------------------------------------------------------------------------- @@ -2630,6 +2636,9 @@ type FsiEvaluationSession (fsi: FsiEvaluationSessionHostConfig, argv:string[], i /// Event fires every time an assembly reference is added to the execution environment, e.g., via `#r`. member __.AssemblyReferenceAdded = fsiDynamicCompiler.AssemblyReferenceAdded + + /// Event fires when a root-level value is bound to an identifier, e.g., via `let x = ...`. + member __.ValueBound = fsiDynamicCompiler.ValueBound /// Performs these steps: /// - Load the dummy interaction, if any diff --git a/src/fsharp/fsi/fsi.fsi b/src/fsharp/fsi/fsi.fsi index bed1b74e61a..c576a33fbdc 100644 --- a/src/fsharp/fsi/fsi.fsi +++ b/src/fsharp/fsi/fsi.fsi @@ -237,6 +237,9 @@ type FsiEvaluationSession = /// Event fires every time an assembly reference is added to the execution environment, e.g., via `#r`. member AssemblyReferenceAdded : IEvent + /// Event fires when a root-level value is bound to an identifier, e.g., via `let x = ...`. + member ValueBound : IEvent + /// Load the dummy interaction, load the initial files, and, /// if interacting, start the background thread to read the standard input. /// diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 9b4707b7872..70b6b2662e8 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -122,3 +122,49 @@ type InteractiveTests() = Assert.True(wasCancelled) Assert.LessOrEqual(sw.ElapsedMilliseconds, sleepTime) Assert.AreEqual(None, result) + + [] + member _.``Values bound at the root trigger an event``() = + let mutable foundX = false + let mutable foundY = false + let mutable foundCount = 0 + use script = new FSharpScript() + script.ValueBound + |> Event.add (fun (value, typ, name) -> + foundX <- foundX || (name = "x" && typ = typeof && value :?> int = 1) + foundY <- foundY || (name = "y" && typ = typeof && value :?> int = 2) + foundCount <- foundCount + 1) + let code = @" +let x = 1 +let y = 2 +" + script.Eval(code) |> ignoreValue + Assert.True(foundX) + Assert.True(foundY) + Assert.AreEqual(2, foundCount) + + [] + member _.``Values re-bound trigger an event``() = + let mutable foundXCount = 0 + use script = new FSharpScript() + script.ValueBound + |> Event.add (fun (_value, typ, name) -> + if name = "x" && typ = typeof then foundXCount <- foundXCount + 1) + script.Eval("let x = 1") |> ignoreValue + script.Eval("let x = 2") |> ignoreValue + Assert.AreEqual(2, foundXCount) + + [] + member _.``Nested let bindings don't trigger event``() = + let mutable foundInner = false + use script = new FSharpScript() + script.ValueBound + |> Event.add (fun (_value, _typ, name) -> + foundInner <- foundInner || name = "inner") + let code = @" +let x = + let inner = 1 + () +" + script.Eval(code) |> ignoreValue + Assert.False(foundInner)