diff --git a/azure-pipelines-PR.yml b/azure-pipelines-PR.yml index c812294cf5a..8647164d91a 100644 --- a/azure-pipelines-PR.yml +++ b/azure-pipelines-PR.yml @@ -124,17 +124,8 @@ stages: - script: .\eng\common\dotnet.cmd - script: .\eng\test-determinism.cmd -configuration Release displayName: Determinism tests (race detector — same flags both builds) - # Hard gate: any non-determinism between two same-flags Release builds fails CI. - # The single known-racy binary, FSharp.Compiler.Service.dll, is excluded via the - # skipList in eng/test-determinism.ps1 — its residual parallel-optimizer - # newUnique() closure-name race (func2@1-N suffix permutation) is tracked in - # #19928 and fixed by #19929 (always-defer + source-stable closure naming). - # #19810 fixes the structural/heap-order races (#1-7), which are deterministic. - # #19929 removes the skip and restores full coverage once the closure race lands. - # The seq-vs-par leg is intentionally NOT here. It catches a deeper architectural - # issue with parallel optimizer's newUnique() race leaking into closure type names — - # see #19928 / #19929. Same-flags Release-mode determinism (the original #19732 ask) - # fixes the structural races here; the residual closure-name race is fixed in #19929. + - script: .\eng\test-determinism.cmd -configuration Release -mode seq-vs-par + displayName: Determinism tests (1-shot diff — sequential vs parallel) - task: PublishPipelineArtifact@1 displayName: Publish Determinism Logs inputs: diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md index f9089d754ba..37196c58067 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.100.md @@ -1,5 +1,8 @@ ### Fixed +* Fix state machine lowering dropping the side-effectful receiver of an unused unit-typed member access (e.g. inside `task { (effectful()).UnitProp }`). ([Issue #13099](https://github.com/dotnet/fsharp/issues/13099), [PR #19885](https://github.com/dotnet/fsharp/pull/19885)) +* `--deterministic` Release builds now produce byte-identical `FSharp.Compiler.Service.dll` under `--parallelcompilation+` and `--parallelcompilation-`, so it is restored to the determinism gate (now also checked sequential-vs-parallel). Code generation runs the same deferred per-file drain in both modes, with type/member/field emit-order keys and generated names derived from the file being emitted rather than thread-scheduling order. ([Issue #19928](https://github.com/dotnet/fsharp/issues/19928), [PR #19929](https://github.com/dotnet/fsharp/pull/19929)) +* Fix `[]` silently producing duplicate IL entries (FS0192/FS2014) when applied to a multi-value let-binding (e.g. `let a, b = 1, 2`); now emits FS0755 at type-check time. ([Issue #6131](https://github.com/dotnet/fsharp/issues/6131), [PR #19924](https://github.com/dotnet/fsharp/pull/19924)) * Fix missing FS1182 ("unused binding") warning for unused `let` function bindings inside class types. ([Issue #13849](https://github.com/dotnet/fsharp/issues/13849), [PR #19805](https://github.com/dotnet/fsharp/pull/19805)) * Fix inner mutually-recursive `let rec ... and ...` functions under `--realsig+` not being lifted to top-level static methods (TLR), causing `FSharpFunc` closure allocations and loss of `tail.` opcodes — the large struct-mutual-recursion perf regression reported in [Issue #17607](https://github.com/dotnet/fsharp/issues/17607). ([PR #19882](https://github.com/dotnet/fsharp/pull/19882)) * Fix `TypeLoadException` ("Specialize tried to implicitly override a method with weaker type parameter constraints") and the related CLR crash with constrained inline calls by stripping constraints from closure-class typars in `EraseClosures.convIlxClosureDef`. ([Issue #14492](https://github.com/dotnet/fsharp/issues/14492), [Issue #19075](https://github.com/dotnet/fsharp/issues/19075), [PR #19882](https://github.com/dotnet/fsharp/pull/19882)) @@ -35,6 +38,7 @@ * Fix inner mutually-recursive `let rec ... and ...` functions under `--realsig+` not being lifted to top-level static methods (TLR), causing `FSharpFunc` closure allocations and loss of `tail.` opcodes — the large struct-mutual-recursion perf regression reported in [Issue #17607](https://github.com/dotnet/fsharp/issues/17607). ([PR #19882](https://github.com/dotnet/fsharp/pull/19882)) * Fix `TypeLoadException` ("Specialize tried to implicitly override a method with weaker type parameter constraints") and the related CLR crash with constrained inline calls by stripping constraints from closure-class typars in `EraseClosures.convIlxClosureDef`. ([Issue #14492](https://github.com/dotnet/fsharp/issues/14492), [Issue #19075](https://github.com/dotnet/fsharp/issues/19075), [PR #19882](https://github.com/dotnet/fsharp/pull/19882)) * Fix `FieldAccessException` at runtime when the optimizer relocates a read of a `protected` (family) base-class field into a method outside the field's family (e.g. a trivial member inlined into module/startup code under `--optimize+`). Protected (family) IL field access is no longer hoisted out of its declaring family by inlining or method-splitting. ([Issue #19963](https://github.com/dotnet/fsharp/issues/19963), [PR #19964](https://github.com/dotnet/fsharp/pull/19964)) + * Suppress hover/symbol resolution for wildcard `_` patterns inside `member _.…` bodies that incorrectly showed `val _: T` tooltip. ([PR #19760](https://github.com/dotnet/fsharp/pull/19760)) * Report `seq { }` implicit-yield diagnostics and format specifier locations once instead of twice: the classification pass that decides whether the body is a statement or a yielded element no longer double-reports to the sink or diagnostics. ([Issue #16419](https://github.com/dotnet/fsharp/issues/16419), [PR #19791](https://github.com/dotnet/fsharp/pull/19791), [PR #19895](https://github.com/dotnet/fsharp/pull/19895)) * Stabilize codegen order under `--parallelcompilation+` so `--deterministic` Release builds produce byte-identical IL across rebuilds: optimizer Val iteration, IlxGen type/method/field/event emit order, anonymous-record extra-binding drain, and `FileIndex` assignment now follow source position rather than thread-scheduling order. ([Issue #19732](https://github.com/dotnet/fsharp/issues/19732), [PR #19810](https://github.com/dotnet/fsharp/pull/19810)) @@ -78,6 +82,7 @@ * Fix O(n) `TypeStructure.GetHashCode` performance regression causing sustained high CPU in IDE mode with generative type providers. ([Issue #18925](https://github.com/dotnet/fsharp/issues/18925), [PR #19369](https://github.com/dotnet/fsharp/pull/19369)) * Fix TypeLoadException when creating delegate with voidptr parameter. (Issue [#11132](https://github.com/dotnet/fsharp/issues/11132), [PR #19338](https://github.com/dotnet/fsharp/pull/19338)) * Suppress tail calls when localloc (NativePtr.stackalloc) is used. (Issue [#13447](https://github.com/dotnet/fsharp/issues/13447), [PR #19338](https://github.com/dotnet/fsharp/pull/19338)) +* Fix stack overflow when graph-checking long statement sequences on platforms with large stack frames (e.g. Mono ppc64le), by flattening `SynExpr.Sequential` chains in `FileContentMapping`. ([Issue #19988](https://github.com/dotnet/fsharp/issues/19988), [PR #20028](https://github.com/dotnet/fsharp/pull/20028)) * Fix TypeLoadException in Release builds with inline constraints. (Issue [#14492](https://github.com/dotnet/fsharp/issues/14492), [PR #19338](https://github.com/dotnet/fsharp/pull/19338)) * Fix nativeptr in interfaces leads to TypeLoadException. (Issue [#14508](https://github.com/dotnet/fsharp/issues/14508), [PR #19338](https://github.com/dotnet/fsharp/pull/19338)) * Fix box instruction for literal upcasts. (Issue [#18319](https://github.com/dotnet/fsharp/issues/18319), [PR #19338](https://github.com/dotnet/fsharp/pull/19338)) @@ -121,6 +126,7 @@ * Reference assembly MVIDs are now deterministic across compiler invocations. Previously, `--refout` / `true` produced a different MVID every build because the implied signature hash used .NET's randomized `String.GetHashCode()`. ([Issue #19751](https://github.com/dotnet/fsharp/issues/19751), [PR #19801](https://github.com/dotnet/fsharp/pull/19801)) * Parser: recover on unfinished if and binary expressions ([PR #19724](https://github.com/dotnet/fsharp/pull/19724)) +* Fix `SynExpr.shouldBeParenthesizedInContext` to report parentheses as required around `SynExpr.Sequential` expressions used as record or anonymous-record field values, so the IDE "remove unnecessary parentheses" analyzer no longer breaks code like `{| A = ((); B = 3) |}`. ([Issue #17826](https://github.com/dotnet/fsharp/issues/17826), [PR #19850](https://github.com/dotnet/fsharp/pull/19850)) * Warn FS3888 when a compiler-semantic attribute on a value/member or type/module is present in the `.fs` but missing from the `.fsi`. Such attributes were previously ignored at the consumer side. Under the `ErrorOnMissingSignatureAttribute` preview language feature, FS3888 is an error. ([Issue #19560](https://github.com/dotnet/fsharp/issues/19560), [PR #19880](https://github.com/dotnet/fsharp/pull/19880)) * Emit debug points at a stack-empty position ([PR #19877](https://github.com/dotnet/fsharp/pull/19877)) * Fix spurious XmlDoc warnings (unknown parameter / no documentation for parameter) under `--warnon:3390` when a get/set property documents the full parameter set across both accessors. ([Issue #13684](https://github.com/dotnet/fsharp/issues/13684), [PR #19884](https://github.com/dotnet/fsharp/pull/19884)) @@ -132,6 +138,7 @@ * Warn FS3888 when a compiler-semantic attribute on a value/member or type/module is present in the `.fs` but missing from the `.fsi`. Such attributes were previously ignored at the consumer side. Under the `ErrorOnMissingSignatureAttribute` preview language feature, FS3888 is an error. ([Issue #19560](https://github.com/dotnet/fsharp/issues/19560), [PR #19880](https://github.com/dotnet/fsharp/pull/19880)) * Emit debug points at a stack-empty position ([PR #19877](https://github.com/dotnet/fsharp/pull/19877)) * Fix spurious XmlDoc warnings (unknown parameter / no documentation for parameter) under `--warnon:3390` when a get/set property documents the full parameter set across both accessors. ([Issue #13684](https://github.com/dotnet/fsharp/issues/13684), [PR #19884](https://github.com/dotnet/fsharp/pull/19884)) +* Fix Go to Metadata rendering of IL literal (`const`) fields - they now appear with `[]` and their constant value, e.g. `System.Char.MaxValue` no longer shows as a plain `static val`. ([Issue #11526](https://github.com/dotnet/fsharp/issues/11526), [PR #19922](https://github.com/dotnet/fsharp/pull/19922)) * FSI multi-assembly emit (`--multiemit+`) now attaches `System.Diagnostics.DebuggableAttribute(DisableOptimizations|Default)` to each submission's manifest when local optimizations are disabled (`--optimize-`), matching the single-emit and regular-compiler behavior so debuggers see submissions as unoptimized. ([Issue #14572](https://github.com/dotnet/fsharp/issues/14572), [PR #19921](https://github.com/dotnet/fsharp/pull/19921)) * Stop F# Interactive from mutating script arguments that follow `--`. Abbreviated flags like `-d`, `-r`, `-I` after the `--` separator are no longer colon-joined with their next token in `fsi.CommandLineArgs`. ([Issue #10819](https://github.com/dotnet/fsharp/issues/10819), [PR #19926](https://github.com/dotnet/fsharp/pull/19926)) * Fix Go-to-Definition for provided constructors that lack `TypeProviderDefinitionLocationAttribute`. Navigation now falls back to the declaring type instead of silently failing. ([Issue #5538](https://github.com/dotnet/fsharp/issues/5538), [PR #19917](https://github.com/dotnet/fsharp/pull/19917)) diff --git a/eng/restore-internal-tools.yml b/eng/restore-internal-tools.yml index 01cd835c5b7..6cb82b12780 100644 --- a/eng/restore-internal-tools.yml +++ b/eng/restore-internal-tools.yml @@ -1,7 +1,9 @@ steps: - task: NuGetAuthenticate@1 + displayName: Authenticate devdiv/dotnet-core-internal-tooling feed (WIF) inputs: - nuGetServiceConnections: 'devdiv/dotnet-core-internal-tooling' + azureDevOpsServiceConnection: dnceng-devdiv-dotnet-core-internal-tooling-feed-rw-wif + feedUrl: https://pkgs.dev.azure.com/devdiv/_packaging/dotnet-core-internal-tooling/nuget/v3/index.json forceReinstallCredentialProvider: true - script: $(Build.SourcesDirectory)\eng\RestoreInternal.cmd diff --git a/eng/test-determinism.ps1 b/eng/test-determinism.ps1 index 35e3a3dadb9..1984acc01a7 100644 --- a/eng/test-determinism.ps1 +++ b/eng/test-determinism.ps1 @@ -27,17 +27,11 @@ if ($help) { } # List of binary names that should be skipped because they have a known issue that -# makes them non-deterministic. -# -# FSharp.Compiler.Service.dll: closure type names carry a "-N" suffix whose counter is -# allocated in parallel-emit order. The closure 'uniq' values come from a racy -# Interlocked.Increment, so two same-flags parallel builds can allocate the suffixes in a -# different order (e.g. func2@1-23 vs func2@1-17), drifting the #Strings heap layout. -# This is the residual closure-name race tracked by -# https://github.com/dotnet/fsharp/issues/19928 and fixed by #19929 (always-defer + -# source-stable closure naming). Skip this one binary until that fix lands so the gate -# can stay STRICT for every other binary instead of being globally suppressed. -$script:skipList = @("FSharp.Compiler.Service.dll") +# makes them non-deterministic. Empty: the closure type-name race that made +# FSharp.Compiler.Service.dll non-deterministic (#19928) is fixed - closure names now bucket +# by the file being emitted, not by the closure's own (inlined or synthetic) source file - so +# the gate stays STRICT for every binary. +$script:skipList = @() function Run-Build([string]$rootDir, [string]$increment, [string]$additionalFscFlags = "") { $logFileName = $increment @@ -199,13 +193,12 @@ function Test-MapContents($dataMap) { throw "Didn't find the expected count of binaries" } - # Test for some well known binaries. - # NOTE: FSharp.Compiler.Service.dll is intentionally NOT listed here — it is excluded via - # $script:skipList above (known parallel closure-name race, #19928/#19929) so it never enters - # the map. Re-add it here once #19929 removes the skip. FSharp.Core.dll remains as the anchor - # guaranteeing we actually examined real compiler output. + # Test for some well known binaries. FSharp.Compiler.Service.dll is the large multi-file + # output that exercised the closure-name race (#19928); FSharp.Core.dll anchors that we + # actually examined real compiler output. $list = @( - "FSharp.Core.dll") + "FSharp.Core.dll", + "FSharp.Compiler.Service.dll") foreach ($fileName in $list) { $found = $false diff --git a/src/Compiler/Checking/Expressions/CheckExpressions.fs b/src/Compiler/Checking/Expressions/CheckExpressions.fs index 1b1007c6729..aba29d0aa86 100644 --- a/src/Compiler/Checking/Expressions/CheckExpressions.fs +++ b/src/Compiler/Checking/Expressions/CheckExpressions.fs @@ -1535,6 +1535,25 @@ let MakeAndPublishVal (cenv: cenv) env (altActualParent, inSig, declKind, valRec vspec let MakeAndPublishVals (cenv: cenv) env (altActualParent, inSig, declKind, valRecInfo, valSchemes, attrs, xmlDoc, literalValue) = + let g = cenv.g + + // [] on a binding that publishes more than one val (e.g. tuple, + // record, list, cons, `let x as y = ...` destructures, multi-case active patterns) + // would silently propagate the same compiled name to every introduced value and + // produce duplicate IL entries (FS0192/FS2014) during codegen. Catch it here where + // the post-generalization val count is authoritative. See dotnet/fsharp#6131. + if Map.count valSchemes > 1 then + match attrs with + | ValAttribString g WellKnownValAttributes.CompiledNameAttribute _ -> + let m = + match Map.toList valSchemes with + | [] -> range0 + | (_, ValScheme(id = id)) :: rest -> + (id.idRange, rest) + ||> List.fold (fun acc (_, ValScheme(id = id)) -> unionRanges acc id.idRange) + errorR(Error(FSComp.SR.tcCompiledNameAttributeMisused(), m)) + | _ -> () + Map.foldBack (fun name (valscheme: ValScheme) values -> Map.add name (MakeAndPublishVal cenv env (altActualParent, inSig, declKind, valRecInfo, valscheme, attrs, xmlDoc, literalValue, false), valscheme.GeneralizedType) values) diff --git a/src/Compiler/Checking/NicePrint.fs b/src/Compiler/Checking/NicePrint.fs index 31fae349f11..91751d5c8e5 100644 --- a/src/Compiler/Checking/NicePrint.fs +++ b/src/Compiler/Checking/NicePrint.fs @@ -463,7 +463,8 @@ module PrintIL = let s = d.ToString ("g12", CultureInfo.InvariantCulture) let s = ensureFloat s s |> (tagNumericLiteral >> Some) - | _ -> None + | ILFieldInit.String s -> ("\"" + s + "\"") |> (tagStringLiteral >> Some) + | ILFieldInit.Null -> "null" |> (tagKeyword >> Some) | None -> None match textOpt with | None -> WordL.equals ^^ (comment "value unavailable") @@ -1972,6 +1973,11 @@ module TastDefinitionPrinting = let nameL = ConvertLogicalNameToDisplayLayout (tagField >> wordL) finfo.FieldName let typL = layoutType denv (finfo.FieldType(infoReader.amap, m)) let fieldL = staticL ^^ WordL.keywordVal ^^ (nameL |> addColonL) ^^ typL + let isLiteral = finfo.LiteralValue.IsSome + let fieldL = + if isLiteral then fieldL ^^ PrintIL.layoutILFieldInit finfo.LiteralValue + else fieldL + let fieldL = fieldL |> PrintTypes.layoutAttribs denv None isLiteral TyparKind.Type [] layoutXmlDocOfILFieldInfo denv infoReader finfo fieldL let layoutEventInfo denv (infoReader: InfoReader) m (einfo: EventInfo) = diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index ff82231e380..986acc7bba6 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -1995,33 +1995,45 @@ let MergePropertyDefs m ilPropertyDefs = ilPropertyDefs |> List.iter (AddPropertyDefToHash m ht) HashRangeSorted ht +[] +type CodegenFileScope private () = + [] + static val mutable private currentFileIdx: int + + static member OrderKey(localIdx: int) : struct (int * int) = + System.Diagnostics.Debug.Assert(CodegenFileScope.currentFileIdx > 0, "OrderKey called outside CodegenFileScope.With") + struct (CodegenFileScope.currentFileIdx, localIdx) + + static member With(fileIdx: int, action: unit -> 'T) : 'T = + let prev = CodegenFileScope.currentFileIdx + + try + CodegenFileScope.currentFileIdx <- fileIdx + action () + finally + CodegenFileScope.currentFileIdx <- prev + //-------------------------------------------------------------------------- // Buffers for compiling modules. The entire assembly gets compiled via an AssemblyBuilder //-------------------------------------------------------------------------- /// Information collected imperatively for each type definition type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = - let mutable methodIdx = 0 - - let gmethods = - let initial = tdef.Methods.AsList() - - let xs = ResizeArray(initial.Length) + let keyed (initial: 'T list) = + let xs = ResizeArray(initial.Length) - for m in initial do - let k = methodIdx - methodIdx <- methodIdx + 1 - xs.Add(struct (m.Name, k), m) + for x in initial do + xs.Add(CodegenFileScope.OrderKey xs.Count, x) xs - let gfields = ResizeArray(tdef.Fields.AsList()) + let gmethods = keyed (tdef.Methods.AsList()) + let gfields = keyed (tdef.Fields.AsList()) + let gevents = keyed (tdef.Events.AsList()) let gproperties: Dictionary = Dictionary<_, _>(3, HashIdentity.Structural) - let gevents = ResizeArray(tdef.Events.AsList()) - let gnested = TypeDefsBuilder() member _.Close(g: TcGlobals) = @@ -2041,45 +2053,23 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = else tdef.CustomAttrs - // Methods come from two sources with different ordering semantics: - // 1. User method definitions added during the sequential spine walk (ctors, - // properties, member bindings). Preserve insertion order for these. - // 2. Deferred-codegen methods (closure invokers with '@' in name) — sort by - // name for deterministic parallel-emit ordering. - let sortedMethods = - let userMethods = ResizeArray() - let deferredMethods = ResizeArray() - - for entry in gmethods do - let struct (name, _) = fst entry - - if name.Contains("@") then - deferredMethods.Add(entry) - else - userMethods.Add(entry) - - let sortedUser = - userMethods - |> Seq.sortBy (fun (struct (_, k), _) -> k) - |> Seq.map snd - |> List.ofSeq - - let sortedDeferred = deferredMethods |> Seq.sortBy fst |> Seq.map snd |> List.ofSeq - - sortedUser @ sortedDeferred + let sortByKey (xs: ResizeArray) = + xs |> Seq.sortBy fst |> Seq.map snd |> List.ofSeq tdef.With( - methods = mkILMethods sortedMethods, - fields = mkILFields (List.ofSeq gfields), + methods = mkILMethods (sortByKey gmethods), + fields = mkILFields (sortByKey gfields), properties = mkILProperties (tdef.Properties.AsList() @ HashRangeSorted gproperties), - events = mkILEvents (List.ofSeq gevents), + events = mkILEvents (sortByKey gevents), nestedTypes = mkILTypeDefs (tdef.NestedTypes.AsList() @ gnested.Close(g)), customAttrs = storeILCustomAttrs attrs ) - member _.AddEventDef(edef: ILEventDef) = gevents.Add(edef) + member _.AddEventDef(edef: ILEventDef) = + gevents.Add(CodegenFileScope.OrderKey gevents.Count, edef) - member _.AddFieldDef(ilFieldDef: ILFieldDef) = gfields.Add(ilFieldDef) + member _.AddFieldDef(ilFieldDef: ILFieldDef) = + gfields.Add(CodegenFileScope.OrderKey gfields.Count, ilFieldDef) member _.AddMethodDef(ilMethodDef: ILMethodDef) = let discard = @@ -2088,9 +2078,7 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = | None -> false if not discard then - let k = methodIdx - methodIdx <- methodIdx + 1 - gmethods.Add(struct (ilMethodDef.Name, k), ilMethodDef) + gmethods.Add(CodegenFileScope.OrderKey gmethods.Count, ilMethodDef) member _.NestedTypeDefs = gnested @@ -2107,34 +2095,23 @@ type TypeDefBuilder(tdef: ILTypeDef, tdefDiscards) = if not discard then AddPropertyDefToHash m gproperties pdef - member _.AppendInstructionsToSpecificMethodDef(cond, instrs, tag, imports) = - match gmethods |> Seq.tryFindIndex (fun (_, md) -> cond md) with + member private this.UpdateOrAddCctor(cond, instrs, tag, imports, transform) = + match ResizeArray.tryFindIndexi (fun _ (_, md) -> cond md) gmethods with | Some idx -> let k, md = gmethods[idx] - gmethods[idx] <- (k, appendInstrsToMethod instrs md) + gmethods[idx] <- (k, transform instrs md) | None -> let body = mkMethodBody (false, [], 1, nonBranchingInstrsToCode instrs, tag, imports) let cctor = mkILClassCtor body - let k = methodIdx - methodIdx <- methodIdx + 1 - gmethods.Add(struct (cctor.Name, k), cctor) - - member this.PrependInstructionsToSpecificMethodDef(cond, instrs, tag, imports) = - match gmethods |> Seq.tryFindIndex (fun (_, md) -> cond md) with - | Some idx -> - let k, md = gmethods[idx] - gmethods[idx] <- (k, prependInstrsToMethod instrs md) - | None -> - let body = - mkMethodBody (false, [], 1, nonBranchingInstrsToCode instrs, tag, imports) + gmethods.Add(CodegenFileScope.OrderKey gmethods.Count, cctor) - let cctor = mkILClassCtor body - let k = methodIdx - methodIdx <- methodIdx + 1 - gmethods.Add(struct (cctor.Name, k), cctor) + member this.AppendInstructionsToSpecificMethodDef(cond, instrs, tag, imports) = + this.UpdateOrAddCctor(cond, instrs, tag, imports, appendInstrsToMethod) + member this.PrependInstructionsToSpecificMethodDef(cond, instrs, tag, imports) = + this.UpdateOrAddCctor(cond, instrs, tag, imports, prependInstrsToMethod) this member _.ILTypeDef = tdef @@ -2475,27 +2452,16 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf // A memoization table for generating value types for big constant arrays // - let primedRawTypeCounter = - ConcurrentDictionary(HashIdentity.Structural) - let rawDataValueTypeGenerator = - MemoizationTable( + MemoizationTable( "rawDataValueTypeGenerator", - (fun (cloc, size) -> - - let unique = - match primedRawTypeCounter.TryGetValue((cloc, size)) with - | true, c -> c - // Prime-miss fallback (e.g. quotation pickle bytes / numeric-literal arrays the source - // prime walk never sees) stays same-flags deterministic: IncrementOnly buckets per - // (name, FileIndex) and the delayed-codegen drain is sequential within a file, so each - // file gets a stable counter. (#19929 removes this counter via content-derived naming.) - | _ -> g.CompilerGlobalState.Value.IlxGenNiceNameGenerator.IncrementOnly("@T", cloc.Range) + (fun (parentRef, size) -> + let name = CompilerGeneratedName $"T_{size}Bytes" + let vtdef = mkRawDataValueTypeDef g.iltyp_ValueType (name, size, 0us) - let name = CompilerGeneratedName $"T{unique}_{size}Bytes" // Type names ending ...$T_37Bytes + let vtref = + mkILNestedTyRef (parentRef.Scope, parentRef.Enclosing @ [ parentRef.Name ], vtdef.Name) - let vtdef = mkRawDataValueTypeDef g.iltyp_ValueType (name, size, 0us) - let vtref = NestedTypeRefForCompLoc cloc vtdef.Name let vtspec = mkILTySpec (vtref, []) let vtdef = @@ -2506,6 +2472,12 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf keyComparer = HashIdentity.Structural ) + let rawDataLineCounters = + ConcurrentDictionary(HashIdentity.Structural) + + let fieldSpecByRange = + ConcurrentDictionary>(HashIdentity.Structural) + let mutable explicitEntryPointInfo: ILTypeRef option = None /// static init fields on script modules. @@ -2545,29 +2517,35 @@ and AssemblyBuilder(cenv: cenv, anonTypeTable: AnonTypeGenerationTable) as mgbuf | None -> () member _.GenerateRawDataValueType(cloc, size) = - // Byte array literals require a ValueType of size the required number of bytes. - // With fsi.exe, S.R.Emit TypeBuilder CreateType has restrictions when a ValueType VT is nested inside a type T, and T has a field of type VT. - // To avoid this situation, these ValueTypes are generated under the private implementation rather than in the current cloc. [was bug 1532]. let cloc = if cenv.options.isInteractive then CompLocForPrivateImplementationDetails cloc else cloc - rawDataValueTypeGenerator.Apply((cloc, size)) + rawDataValueTypeGenerator.Apply((TypeRefForCompLoc cloc, size)) - member _.PrimeRawDataValueTypeCounter(cloc: CompileLocation, size: int) = - let cloc = - if cenv.options.isInteractive then - CompLocForPrivateImplementationDetails cloc - else - cloc + member this.GetOrCreateRawDataFieldSpec(m: range, bytes: byte[], makeFspec: string -> ILFieldSpec) = + // bytesKey is load-bearing: remarkExpr collapses distinct inline arrays to one range, + // so bytes content is the sole discriminator preventing silent field aliasing. + let bytesKey = System.Convert.ToBase64String(bytes) - primedRawTypeCounter.GetOrAdd( - (cloc, size), - (fun _ -> g.CompilerGlobalState.Value.IlxGenNiceNameGenerator.IncrementOnly("@T", cloc.Range)) - ) - |> ignore + let key = + struct (m.FileIndex, m.StartLine, m.StartColumn, m.EndLine, m.EndColumn, bytesKey) + + fieldSpecByRange + .GetOrAdd( + key, + (fun _ -> + lazy + let counterCell = + rawDataLineCounters.GetOrAdd(struct (m.FileIndex, m.StartLine), (fun _ -> ref 0)) + + let idx = System.Threading.Interlocked.Increment(counterCell) + let nameSuffix = sprintf "%d_%d" m.StartLine idx + makeFspec nameSuffix) + ) + .Value member _.GenerateAnonType(genToStringMethod, anonInfo: AnonRecdTypeInfo) = anonTypeTable.GenerateAnonType(cenv, mgbuf, genToStringMethod, anonInfo) @@ -2959,7 +2937,7 @@ module CG = let GenString cenv cgbuf s = CG.EmitInstr cgbuf (pop 0) (Push [ cenv.g.ilg.typ_String ]) (I_ldstr s) -let GenConstArray cenv (cgbuf: CodeGenBuffer) eenv ilElementType (data: 'a[]) (write: ByteBuffer -> 'a -> unit) (_m: range) = +let GenConstArray cenv (cgbuf: CodeGenBuffer) eenv ilElementType (data: 'a[]) (write: ByteBuffer -> 'a -> unit) (m: range) = let g = cenv.g use buf = ByteBuffer.Create data.Length data |> Array.iter (write buf) @@ -2969,23 +2947,26 @@ let GenConstArray cenv (cgbuf: CodeGenBuffer) eenv ilElementType (data: 'a[]) (w if data.Length = 0 then CG.EmitInstrs cgbuf (pop 0) (Push [ ilArrayType ]) [ mkLdcInt32 0; I_newarr(ILArrayShape.SingleDimensional, ilElementType) ] else - let vtspec = cgbuf.mgbuf.GenerateRawDataValueType(eenv.cloc, bytes.Length) + let fspec = + cgbuf.mgbuf.GetOrCreateRawDataFieldSpec( + m, + bytes, + fun unique -> + let vtspec = cgbuf.mgbuf.GenerateRawDataValueType(eenv.cloc, bytes.Length) + let ilFieldName = CompilerGeneratedName $"field{unique}" + let fty = ILType.Value vtspec - let unique = - g.CompilerGlobalState.Value.IlxGenNiceNameGenerator.IncrementOnly("@field", eenv.cloc.Range) - - let ilFieldName = CompilerGeneratedName $"field{unique}" - let fty = ILType.Value vtspec - - let ilFieldDef = - mkILStaticField (ilFieldName, fty, None, Some bytes, ILMemberAccess.Assembly) + let ilFieldDef = + mkILStaticField (ilFieldName, fty, None, Some bytes, ILMemberAccess.Assembly) - let ilFieldDef = - ilFieldDef.With(customAttrs = mkILCustomAttrs [ g.DebuggerBrowsableNeverAttribute ]) + let ilFieldDef = + ilFieldDef.With(customAttrs = mkILCustomAttrs [ g.DebuggerBrowsableNeverAttribute ]) - let fspec = mkILFieldSpecInTy (mkILTyForCompLoc eenv.cloc, ilFieldName, fty) - CountStaticFieldDef() - cgbuf.mgbuf.AddFieldDef(fspec.DeclaringTypeRef, ilFieldDef) + let fspec = mkILFieldSpecInTy (mkILTyForCompLoc eenv.cloc, ilFieldName, fty) + CountStaticFieldDef() + cgbuf.mgbuf.AddFieldDef(fspec.DeclaringTypeRef, ilFieldDef) + fspec + ) CG.EmitInstrs cgbuf @@ -10983,10 +10964,11 @@ and GenModuleBinding cenv (cgbuf: CodeGenBuffer) (qname: QualifiedNameOfFile) la GenModuleOrNamespaceContents cenv cgbuf qname lazyInitInfo eenvinner mdef |> ignore - // Only force the whole-file .cctor when the module actually has static fields. - // Forcing it unconditionally adds an eager initialization side effect to modules - // with no static state, which changes static-init ordering and caused runtime - // regressions (FSharpPlus testChoice hang, topinit/eval failures). + // Safe: delayCodeGen=true defers raw-data field additions to the drain phase, + // so SEQ and PAR see the same spine-walk-only fields at this point. + if not eenv.delayCodeGen then + invalidOp "HasFields predicate requires delayCodeGen=true for SEQ=PAR safety" + if cgbuf.mgbuf.HasFields(tref) then GenForceWholeFileInitializationAsPartOfCCtor cenv cgbuf.mgbuf lazyInitInfo tref eenv.imports mspec.Range @@ -12696,7 +12678,7 @@ and GenExnDef cenv mgbuf eenv m (exnc: Tycon) : ILTypeRef option = mgbuf.AddTypeDef(tref, tdef, false, false, None, m) Some tref -let PrimeStableNamesForCodegen (cenv: cenv) (mgbuf: AssemblyBuilder) (implFiles: CheckedImplFileAfterOptimization list) = +let PrimeStableNamesForCodegen (cenv: cenv) (implFiles: CheckedImplFileAfterOptimization list) = let g = cenv.g match g.CompilerGlobalState with @@ -12711,199 +12693,93 @@ let PrimeStableNamesForCodegen (cenv: cenv) (mgbuf: AssemblyBuilder) (implFiles: then v.CompiledName g.CompilerGlobalState |> ignore - let stackGuard = StackGuard("PrimeStableNamesForCodegen") - - let rec walkExpr (letBoundVars: ValRef list) (cloc: CompileLocation) (expr: Expr) = - stackGuard.Guard - <| fun () -> - match stripDebugPoints expr with - | Expr.Const _ - | Expr.Val _ - | Expr.WitnessArg _ -> () - - | Expr.Lambda(_, _, _, _, body, _, _) -> walkExpr letBoundVars cloc body - - | Expr.TyLambda(_, _, body, _, _) -> walkExpr letBoundVars cloc body - - | Expr.Obj(_, _, _, basecall, overrides, iimpls, _) -> - walkExpr letBoundVars cloc basecall - - for TObjExprMethod(_, _, _, _, e, _) in overrides do - walkExpr letBoundVars cloc e - - for _, ims in iimpls do - for TObjExprMethod(_, _, _, _, e, _) in ims do - walkExpr letBoundVars cloc e - - | Expr.Let(TBind(v, rhs, _), body, _, _) -> - walkExpr (mkLocalValRef v :: letBoundVars) cloc rhs - walkExpr (mkLocalValRef v :: letBoundVars) cloc body - - | Expr.LetRec(binds, body, _, _) -> - let lbvs = - (binds |> List.map (fun (TBind(v, _, _)) -> mkLocalValRef v)) @ letBoundVars - - for TBind(_, rhs, _) in binds do - walkExpr lbvs cloc rhs - - walkExpr lbvs cloc body - - | Expr.Op(op, _, args, _m) -> - match op with - | TOp.Bytes bytes when cenv.options.emitConstantArraysUsingStaticDataBlobs -> - mgbuf.PrimeRawDataValueTypeCounter(cloc, bytes.Length) - | TOp.UInt16s arr when cenv.options.emitConstantArraysUsingStaticDataBlobs -> - mgbuf.PrimeRawDataValueTypeCounter(cloc, arr.Length * 2) - | _ -> () - - for a in args do - walkExpr letBoundVars cloc a - - | Expr.App(f, _, _, args, _) -> - walkExpr letBoundVars cloc f - - for a in args do - walkExpr letBoundVars cloc a - - | Expr.Sequential(e1, e2, _, _) -> - walkExpr letBoundVars cloc e1 - walkExpr letBoundVars cloc e2 - - | Expr.Match(_, _, dt, targets, _, _) -> - walkDtree letBoundVars cloc dt - - for TTarget(_, body, _) in targets do - walkExpr letBoundVars cloc body - - | Expr.StaticOptimization(_, e2, e3, _) -> - walkExpr letBoundVars cloc e2 - walkExpr letBoundVars cloc e3 - - | Expr.TyChoose(_, body, _) -> walkExpr letBoundVars cloc body - - | Expr.Quote(e, _, _, _, _) -> walkExpr letBoundVars cloc e - - | Expr.Link r -> walkExpr letBoundVars cloc r.Value - - | Expr.DebugPoint(_, inner) -> walkExpr letBoundVars cloc inner - - and walkDtree (letBoundVars: ValRef list) cloc dt = - match dt with - | TDBind(TBind(v, rhs, _), rest) -> - walkExpr (mkLocalValRef v :: letBoundVars) cloc rhs - walkDtree letBoundVars cloc rest - | TDSuccess(args, _) -> - for a in args do - walkExpr letBoundVars cloc a - | TDSwitch(test, cases, dflt, _) -> - walkExpr letBoundVars cloc test - - for TCase(_, sub) in cases do - walkDtree letBoundVars cloc sub - - match dflt with - | Some d -> walkDtree letBoundVars cloc d - | None -> () - - let walkTopBindRhs (v: Val) (rhs: Expr) (cloc: CompileLocation) = - let rec stripOuterTopLambdas (e: Expr) = - match e with - | Expr.TyLambda(_, _, body, _, _) -> stripOuterTopLambdas body - | Expr.Lambda(_, ctorThisValOpt, baseValOpt, _, body, _, _) when Option.isNone ctorThisValOpt && Option.isNone baseValOpt -> - stripOuterTopLambdas body - | _ -> e - - if v.IsCompiledAsTopLevel then - walkExpr [ mkLocalValRef v ] cloc (stripOuterTopLambdas rhs) - else - walkExpr [ mkLocalValRef v ] cloc rhs - - let rec walkModuleContents (cloc: CompileLocation) (x: ModuleOrNamespaceContents) = - match x with - | TMDefRec(_, _, _, mbinds, _) -> - for mb in mbinds do - walkModuleBinding cloc mb - | TMDefLet(TBind(v, rhs, _), _) -> - primeVal v - walkTopBindRhs v rhs cloc - | TMDefDo(e, _) -> walkExpr [] cloc e - | TMDefOpens _ -> () - | TMDefs defs -> - for d in defs do - walkModuleContents cloc d - - and walkModuleBinding (cloc: CompileLocation) (mb: ModuleOrNamespaceBinding) = - match mb with - | ModuleOrNamespaceBinding.Binding(TBind(v, rhs, _)) -> - primeVal v - walkTopBindRhs v rhs cloc - | ModuleOrNamespaceBinding.Module(mspec, mdef) -> - let cloc' = - if mspec.IsNamespace then - cloc - else - CompLocForFixedModule cloc.QualifiedNameOfFile cloc.TopImplQualifiedName mspec - - walkModuleContents cloc' mdef - - let fragCloc = CompLocForFragment cenv.options.fragName cenv.viewCcu + let primingFolder = + { ExprFolder0 with + valBindingSiteIntercept = + fun () (_, v) -> + primeVal v + () + } for implFile in implFiles do - let (CheckedImplFile(qname, _, contents, _, _, _, _)) = implFile.ImplFile - - let fileCloc = - { fragCloc with - TopImplQualifiedName = qname.Text - Range = qname.Range - } - - let initCloc = CompLocForInitClass fileCloc - walkModuleContents initCloc contents + FoldImplFile primingFolder () implFile.ImplFile |> ignore let CodegenAssembly cenv eenv mgbuf implFiles = match List.tryFrontAndBack implFiles with | None -> () | Some(firstImplFiles, lastImplFile) -> - PrimeStableNamesForCodegen cenv mgbuf implFiles + PrimeStableNamesForCodegen cenv implFiles + + // Per-file CodegenFileScope indices are 1-based: firstImplFiles get 1..k, lastImplFile gets k+1, + // and the trailing residue drain gets k+2 (one past the last real file). + let lastImplFileIdx = List.length firstImplFiles + 1 + let residueFileIdx = lastImplFileIdx + 1 + + let eenv, _ = + firstImplFiles + |> List.fold + (fun (eenv, fileIdx) implFile -> + let eenv' = + CodegenFileScope.With(fileIdx, fun () -> GenImplFile cenv mgbuf None eenv implFile) + + eenv', fileIdx + 1) + (eenv, 1) + + let eenv = + CodegenFileScope.With(lastImplFileIdx, fun () -> GenImplFile cenv mgbuf cenv.options.mainMethodInfo eenv lastImplFile) + + let runBatch (fileIdx, genMeths) = + CodegenFileScope.With(fileIdx + 1, fun () -> genMeths |> Array.iter (fun gen -> gen ())) - let eenv = List.fold (GenImplFile cenv mgbuf None) eenv firstImplFiles - let eenv = GenImplFile cenv mgbuf cenv.options.mainMethodInfo eenv lastImplFile + let batches = + eenv.delayedFileGenReverse |> Array.ofList |> Array.rev |> Array.indexed - eenv.delayedFileGenReverse - |> Array.ofList - |> Array.rev - |> ArrayParallel.iter (fun genMeths -> genMeths |> Array.iter (fun gen -> gen ())) + if cenv.options.parallelIlxGenEnabled then + batches |> ArrayParallel.iter runBatch + else + batches |> Array.iter runBatch - // Some constructs generate residue types and bindings. Generate these now. They don't result in any - // top-level initialization code. + // Some constructs generate residue types and bindings (e.g. anon-record structural-equality + // augmentations). Generate these now in a trailing file scope past the last real file index so any + // members/closures they emit still key by a positive currentFileIdx: this preserves the OrderKey + // Debug.Assert(currentFileIdx > 0) invariant and keeps them from being hoisted ahead of real + // members via a struct(0, _) key. They don't result in any top-level initialization code. let extraBindings = mgbuf.GrabExtraBindingsToGenerate() //printfn "#extraBindings = %d" extraBindings.Length if extraBindings.Length > 0 then - let mexpr = TMDefs [ for b in extraBindings -> TMDefLet(b, range0) ] + CodegenFileScope.With( + residueFileIdx, + fun () -> + let mexpr = TMDefs [ for b in extraBindings -> TMDefLet(b, range0) ] - let _emptyTopInstrs, _emptyTopCode = - CodeGenMethod - cenv - mgbuf - ([], - "unused", - eenv, - 0, - None, - (fun cgbuf eenv -> - let lazyInitInfo = ResizeArray() - let qname = QualifiedNameOfFile(mkSynId range0 "unused") - - LocalScope "module" cgbuf (fun (_, endMark) -> - let eenv = - AddBindingsForModuleOrNamespaceContents (AllocValReprWithinExpr cenv cgbuf endMark) eenv.cloc eenv mexpr - - let _eenvEnv = GenModuleOrNamespaceContents cenv cgbuf qname lazyInitInfo eenv mexpr - ())), - range0) - //printfn "#_emptyTopInstrs = %d" _emptyTopInstrs.Length - () + let _emptyTopInstrs, _emptyTopCode = + CodeGenMethod + cenv + mgbuf + ([], + "unused", + eenv, + 0, + None, + (fun cgbuf eenv -> + let lazyInitInfo = ResizeArray() + let qname = QualifiedNameOfFile(mkSynId range0 "unused") + + LocalScope "module" cgbuf (fun (_, endMark) -> + let eenv = + AddBindingsForModuleOrNamespaceContents + (AllocValReprWithinExpr cenv cgbuf endMark) + eenv.cloc + eenv + mexpr + + let _eenvEnv = GenModuleOrNamespaceContents cenv cgbuf qname lazyInitInfo eenv mexpr + ())), + range0) + //printfn "#_emptyTopInstrs = %d" _emptyTopInstrs.Length + () + ) mgbuf.AddInitializeScriptsInOrderToEntryPoint(eenv.imports) @@ -13006,7 +12882,7 @@ let GenerateCode (cenv, anonTypeTable, eenv, CheckedAssemblyAfterOptimization im { eenv with cloc = fragLoc moduleCloc = fragLoc - delayCodeGen = cenv.options.parallelIlxGenEnabled + delayCodeGen = true } // Generate the PrivateImplementationDetails type diff --git a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs index 6f13677025b..38ce5a8d8cd 100644 --- a/src/Compiler/Driver/GraphChecking/FileContentMapping.fs +++ b/src/Compiler/Driver/GraphChecking/FileContentMapping.fs @@ -454,8 +454,7 @@ let visitSynExpr (e: SynExpr) : FileContentEntry list = | SynExpr.TryFinally(tryExpr = tryExpr; finallyExpr = finallyExpr) -> visit tryExpr (fun tNodes -> visit finallyExpr (fun fNodes -> tNodes @ fNodes |> continuation)) | SynExpr.Lazy(expr, _) -> visit expr continuation - | SynExpr.Sequential(expr1 = expr1; expr2 = expr2) -> - visit expr1 (fun nodes1 -> visit expr2 (fun nodes2 -> nodes1 @ nodes2 |> continuation)) + | SynExpr.Sequential _ as seqExpr -> Continuation.concatenate (List.map visit (flattenSequentials seqExpr)) continuation | SynExpr.IfThenElse(ifExpr = ifExpr; thenExpr = thenExpr; elseExpr = elseExpr) -> let continuations = List.map visit (ifExpr :: thenExpr :: Option.toList elseExpr) Continuation.concatenate continuations continuation diff --git a/src/Compiler/Optimize/DetupleArgs.fs b/src/Compiler/Optimize/DetupleArgs.fs index 360bf6a22bd..faa83b4b016 100644 --- a/src/Compiler/Optimize/DetupleArgs.fs +++ b/src/Compiler/Optimize/DetupleArgs.fs @@ -704,7 +704,7 @@ let determineTransforms (scope: PerFileNamingScope) g (z: Results) = let vtransforms = Zmap.toList z.Uses - |> List.sortWith (fun (v1, _) (v2, _) -> compare (valSourceOrderKey v1) (valSourceOrderKey v2)) + |> List.sortBy (fst >> valSourceOrderKey) |> List.choose (fun (f, sites) -> selectTransform f sites) let vtransforms = Zmap.ofList valOrder vtransforms vtransforms diff --git a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs index 76e1f443d13..24174f11a45 100644 --- a/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs +++ b/src/Compiler/Optimize/InnerLambdasToTopLevelFuncs.fs @@ -881,7 +881,7 @@ let CreateNewValuesForTLR (scope: PerFileNamingScope) g tlrS arityM fclassM envP let fs = Zset.elements tlrS - |> List.sortWith (fun v1 v2 -> compare (valSourceOrderKey v1) (valSourceOrderKey v2)) + |> List.sortBy valSourceOrderKey let ffHats = List.map (fun f -> f, createFHat f) fs let fHatM = Zmap.ofList valOrder ffHats fHatM diff --git a/src/Compiler/Optimize/LowerStateMachines.fs b/src/Compiler/Optimize/LowerStateMachines.fs index a82d57d0789..9b75685f865 100644 --- a/src/Compiler/Optimize/LowerStateMachines.fs +++ b/src/Compiler/Optimize/LowerStateMachines.fs @@ -175,23 +175,29 @@ type LowerStateMachine(g: TcGlobals, outerResumableCodeDefns: ValMap) = pcCount // Record definitions for any resumable code - let rec BindResumableCodeDefinitions (env: env) expr = + let rec BindResumableCodeDefinitions (env: env) finalizing expr = match expr with // Bind 'let __expand_ABC = bindExpr in bodyExpr' - | Expr.Let (defn, bodyExpr, _, _) when isStateMachineBindingVar g defn.Var -> + | Expr.Let (defn, bodyExpr, m, _) when isStateMachineBindingVar g defn.Var -> if sm_verbose then printfn "binding %A --> %A..." defn.Var defn.Expr let envR = { env with ResumableCodeDefns = env.ResumableCodeDefns.Add defn.Var defn.Expr } - BindResumableCodeDefinitions envR bodyExpr + let envR2, bodyR = BindResumableCodeDefinitions envR finalizing bodyExpr + // A dropped member-access receiver temp loses its side effect when unused (#13099). + if finalizing && defn.Var.IsMemberThisVal && Optimizer.ExprHasEffect Optimizer.EffectContext.Emit g defn.Expr && + not (Zset.contains defn.Var (freeInExpr CollectLocals bodyExpr).FreeLocals) then + envR2, mkSequential m defn.Expr bodyR + else + envR2, bodyR // Eliminate 'if __useResumableCode ...' | IfUseResumableStateMachinesExpr g (thenExpr, _) -> if sm_verbose then printfn "eliminating 'if __useResumableCode...'" - BindResumableCodeDefinitions env thenExpr + BindResumableCodeDefinitions env finalizing thenExpr // Look through debug points to find resumable code bindings inside | Expr.DebugPoint (_, innerExpr) -> - let envR, _ = BindResumableCodeDefinitions env innerExpr + let envR, _ = BindResumableCodeDefinitions env finalizing innerExpr (envR, expr) | _ -> @@ -398,7 +404,7 @@ type LowerStateMachine(g: TcGlobals, outerResumableCodeDefns: ValMap) = /// Repeatedly find outermost expansion definitions and apply outermost expansions let rec RepeatBindAndApplyOuterDefinitions (env: env) expr = if sm_verbose then printfn "RepeatBindAndApplyOuterDefinitions for %A..." expr - let env2, expr2 = BindResumableCodeDefinitions env expr + let env2, expr2 = BindResumableCodeDefinitions env true expr match TryReduceExpr env2 expr2 [] id with | Some res -> RepeatBindAndApplyOuterDefinitions env2 res | None -> env2, expr2 @@ -409,7 +415,7 @@ type LowerStateMachine(g: TcGlobals, outerResumableCodeDefns: ValMap) = // All expanded resumable code state machines e.g. 'task { .. }' begin with a bind of @builder or 'defn' // Seed the env with any expand-var definitions from outer scopes (e.g. across lambda boundaries) let initialEnv = { env.Empty with ResumableCodeDefns = outerResumableCodeDefns } - let env, expr = BindResumableCodeDefinitions initialEnv inputExpr + let env, expr = BindResumableCodeDefinitions initialEnv false inputExpr match expr with | StructStateMachineExpr g (dataTy, diff --git a/src/Compiler/Optimize/Optimizer.fs b/src/Compiler/Optimize/Optimizer.fs index f67072c1c78..4748685287d 100644 --- a/src/Compiler/Optimize/Optimizer.fs +++ b/src/Compiler/Optimize/Optimizer.fs @@ -4692,26 +4692,34 @@ and p_ValInfo (v: ValInfo) st = p_ExprValueInfo v.ValExprInfo st p_bool v.ValMakesNoCriticalTailcalls st -and p_ModuleInfo x st = +and p_ModuleInfo x st = + // Stamp tiebreaker is safe: every Val reaching ValInfos.Entries has its stamp + // assigned during single-threaded type-checking. + let stableValKey (vref: ValRef) = + let k = vref.Deref.GetLinkageFullKey() + + struct ( + vref.LogicalName, + k.PartialKey.MemberParentMangledName, + k.PartialKey.TotalArgCount, + k.PartialKey.MemberIsOverride, + vref.Deref.Stamp + ) + + let mergeRacedFlags (vref: ValRef, vinfo: ValInfo) = + let merged = vinfo.ValMakesNoCriticalTailcalls || vref.Deref.MakesNoCriticalTailcalls + + if merged = vinfo.ValMakesNoCriticalTailcalls then + vref, vinfo + else + vref, { vinfo with ValMakesNoCriticalTailcalls = merged } + let entries = x.ValInfos.Entries |> Seq.toArray - |> Array.sortBy (fun (vref: ValRef, _) -> - let k = vref.Deref.GetLinkageFullKey() - - struct ( - vref.LogicalName, - k.PartialKey.MemberParentMangledName, - k.PartialKey.TotalArgCount, - k.PartialKey.MemberIsOverride, - vref.Deref.Stamp - )) - |> Array.map (fun (vref, vinfo) -> - let merged = vinfo.ValMakesNoCriticalTailcalls || vref.Deref.MakesNoCriticalTailcalls - if merged = vinfo.ValMakesNoCriticalTailcalls then - vref, vinfo - else - vref, { vinfo with ValMakesNoCriticalTailcalls = merged }) + |> Array.sortBy (fst >> stableValKey) + |> Array.map mergeRacedFlags + p_array (p_tup2 (p_vref "opttab") p_ValInfo) entries st p_namemap p_LazyModuleInfo x.ModuleOrNamespaceInfos st diff --git a/src/Compiler/Service/ServiceParsedInputOps.fs b/src/Compiler/Service/ServiceParsedInputOps.fs index 8724712440c..00dbde0eae9 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fs +++ b/src/Compiler/Service/ServiceParsedInputOps.fs @@ -270,19 +270,6 @@ module Entity = module ParsedInput = - /// A pattern that collects all sequential expressions to avoid StackOverflowException - let internal (|Sequentials|_|) expr = - - let rec collect expr acc = - match expr with - | SynExpr.Sequential(expr1 = e1; expr2 = SynExpr.Sequential _ as e2) -> collect e2 (e1 :: acc) - | SynExpr.Sequential(expr1 = e1; expr2 = e2) -> e2 :: e1 :: acc - | _ -> acc - - match collect expr [] with - | [] -> None - | exprs -> Some(List.rev exprs) - let emptyStringSet = HashSet() let GetRangeOfExprLeftOfDot (pos: pos, parsedInput) = diff --git a/src/Compiler/Service/ServiceParsedInputOps.fsi b/src/Compiler/Service/ServiceParsedInputOps.fsi index d99277893d4..b063468dc50 100644 --- a/src/Compiler/Service/ServiceParsedInputOps.fsi +++ b/src/Compiler/Service/ServiceParsedInputOps.fsi @@ -160,8 +160,6 @@ type public InsertionContextEntity = /// Operations querying the entire syntax tree module public ParsedInput = - /// A pattern that collects all sequential expressions to avoid StackOverflowException - val internal (|Sequentials|_|): SynExpr -> SynExpr list option val TryFindExpressionASTLeftOfDotLeftOfCursor: pos: pos * parsedInput: ParsedInput -> (pos * bool) option diff --git a/src/Compiler/Service/SynExpr.fs b/src/Compiler/Service/SynExpr.fs index d1d0c6eb4c3..8a81d77193e 100644 --- a/src/Compiler/Service/SynExpr.fs +++ b/src/Compiler/Service/SynExpr.fs @@ -1093,6 +1093,11 @@ module SynExpr = | SynInterpolatedStringPart.FillExpr(qualifiers = Some _) -> true | _ -> false) + // {| A = (1; 2) |} + // { A = (1; 2) } + // Removing the parens would let the semicolon be parsed as a field separator. + | (SynExpr.Record _ | SynExpr.AnonRecd _), SynExpr.Sequential _ -> true + // { (!x) with … } | SynExpr.Record(copyInfo = Some(SynExpr.Paren(expr = Is inner), _)), SynExpr.App(isInfix = false; funcExpr = FuncExpr.SymbolicOperator(StartsWith('!' | '~'))) diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs index 1fb56dd697d..fa30545d480 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fs +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fs @@ -299,6 +299,22 @@ let (|SynExprParen|_|) (e: SynExpr) = | SynExpr.Paren(SynExprErrorSkip e, a, b, c) -> ValueSome(e, a, b, c) | _ -> ValueNone +/// Collects the ordered sub-expressions of nested `SynExpr.Sequential`, avoiding deep recursion (empty if not a Sequential). +let flattenSequentials expr = + let rec collect expr acc = + match expr with + | SynExpr.Sequential(expr1 = e1; expr2 = SynExpr.Sequential _ as e2) -> collect e2 (e1 :: acc) + | SynExpr.Sequential(expr1 = e1; expr2 = e2) -> e2 :: e1 :: acc + | _ -> acc + + List.rev (collect expr []) + +/// A pattern that collects all sequential expressions to avoid StackOverflowException +let (|Sequentials|_|) expr = + match flattenSequentials expr with + | [] -> None + | exprs -> Some exprs + let (|SynPatErrorSkip|) (p: SynPat) = match p with | SynPat.FromParseError(p, _) -> p diff --git a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi index cb5fe46a1b6..246d661e663 100644 --- a/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi +++ b/src/Compiler/SyntaxTree/SyntaxTreeOps.fsi @@ -87,6 +87,12 @@ val (|SynExprErrorSkip|): p: SynExpr -> SynExpr [] val (|SynExprParen|_|): e: SynExpr -> (SynExpr * range * range option * range) voption +/// Collects the ordered sub-expressions of nested `SynExpr.Sequential`, avoiding deep recursion (empty if not a Sequential). +val flattenSequentials: expr: SynExpr -> SynExpr list + +/// A pattern that collects all sequential expressions to avoid StackOverflowException +val (|Sequentials|_|): SynExpr -> SynExpr list option + val (|SynPatErrorSkip|): p: SynPat -> SynPat /// Push non-simple parts of a patten match over onto the r.h.s. of a lambda. diff --git a/src/Compiler/TypedTree/CompilerGlobalState.fs b/src/Compiler/TypedTree/CompilerGlobalState.fs index d658920787a..dfc8bb0abbe 100644 --- a/src/Compiler/TypedTree/CompilerGlobalState.fs +++ b/src/Compiler/TypedTree/CompilerGlobalState.fs @@ -40,8 +40,6 @@ type NiceNameGenerator() = member this.FreshCompilerGeneratedName (name, m: range) = this.FreshCompilerGeneratedNameOfBasicName (GetBasicNameOfPossibleCompilerGeneratedName name, m) - member _.IncrementOnly(name: string, m: range) = increment name m - member _.FreshCompilerGeneratedNameInScope (scopeFileIndex: int, name: string, m: range) = let basicName = GetBasicNameOfPossibleCompilerGeneratedName name let count = incrementBucket basicName scopeFileIndex diff --git a/src/Compiler/TypedTree/CompilerGlobalState.fsi b/src/Compiler/TypedTree/CompilerGlobalState.fsi index 91689196ade..cf357d066be 100644 --- a/src/Compiler/TypedTree/CompilerGlobalState.fsi +++ b/src/Compiler/TypedTree/CompilerGlobalState.fsi @@ -17,7 +17,6 @@ type NiceNameGenerator = new: unit -> NiceNameGenerator member FreshCompilerGeneratedName: name: string * m: range -> string - member IncrementOnly: name: string * m: range -> int /// Generates compiler-generated names marked up with a source code location, but if given the same unique value then /// return precisely the same name. Each name generated also includes the StartLine number of the range passed in diff --git a/src/Compiler/TypedTree/TypedTreeOps.ExprConstruction.fsi b/src/Compiler/TypedTree/TypedTreeOps.ExprConstruction.fsi index 53be76e3cdc..de866c4175d 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.ExprConstruction.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.ExprConstruction.fsi @@ -22,6 +22,7 @@ module internal ExprConstruction = /// An ordering for value definitions, based on stamp val valOrder: IComparer + /// Stable, source-position-derived key for ordering Vals. val valSourceOrderKey: Val -> struct (int * int * int * string) /// An ordering for type definitions, based on stamp diff --git a/tests/AheadOfTime/Trimming/check.ps1 b/tests/AheadOfTime/Trimming/check.ps1 index f6fcf7a591b..49cf96e31d3 100644 --- a/tests/AheadOfTime/Trimming/check.ps1 +++ b/tests/AheadOfTime/Trimming/check.ps1 @@ -62,17 +62,16 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len, $callerLineNumber) { $allErrors = @() -# Check net9.0 trimmed assemblies +# Check net9.0 trimmed assemblies. $allErrors += CheckTrim -root "SelfContained_Trimming_Test" -tfm "net9.0" -outputfile "FSharp.Core.dll" -expected_len 311296 -callerLineNumber 66 # Check net9.0 trimmed assemblies with static linked FSharpCore. -# Placeholder (-1): this app statically links FSharp.Compiler.Service, whose size still -# varies with the parallel-optimizer closure-name residual (#19928, fixed by #19929) and -# the local-vs-CI trimmer toolchain. Pin a real size once #19929 lands. -$allErrors += CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net9.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len -1 -callerLineNumber 69 +# Statically links FSharp.Compiler.Service; the size is stable now that its codegen is +# deterministic (#19928/#19929). Update if compiler/trimming output intentionally changes. +$allErrors += CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net9.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 9173504 -callerLineNumber 71 # Check net9.0 trimmed assemblies with F# metadata resources removed -$allErrors += CheckTrim -root "FSharpMetadataResource_Trimming_Test" -tfm "net9.0" -outputfile "FSharpMetadataResource_Trimming_Test.dll" -expected_len 7612928 -callerLineNumber 72 +$allErrors += CheckTrim -root "FSharpMetadataResource_Trimming_Test" -tfm "net9.0" -outputfile "FSharpMetadataResource_Trimming_Test.dll" -expected_len 7612928 -callerLineNumber 74 # Report all errors and exit with failure if any occurred if ($allErrors.Count -gt 0) { diff --git a/tests/FSharp.Compiler.ComponentTests/Attributes/CompiledNameMultipleValues.fs b/tests/FSharp.Compiler.ComponentTests/Attributes/CompiledNameMultipleValues.fs new file mode 100644 index 00000000000..9628a248599 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Attributes/CompiledNameMultipleValues.fs @@ -0,0 +1,73 @@ +namespace FSharp.Compiler.ComponentTests.Attributes + +open Xunit +open FSharp.Test.Compiler + +module CompiledNameMultipleValues = + + [] + []\nlet a, b = 1, 2")>] + []\nlet (a, b) = 1, 2")>] + []\nlet ((a, b), c) = (1, 2), 3")>] + []\nlet { F = a; G = b } = { F = 1; G = 2 }")>] + []\nlet (Pair(a, b)) = Pair(1, 2)")>] + []\nlet (Some (a, b)) = Some (1, 2)")>] + []\nlet [| a; b |] = [| 1; 2 |]")>] + []\nlet a :: b = [1; 2]")>] + []\nlet (x as y) = 1")>] + let ``CompiledName on multi-value let-binding produces FS0755`` (source: string) = + FSharp source + |> typecheck + |> shouldFail + |> withErrorCode 755 + |> ignore + + [] + let ``CompiledName on tuple binding fires FS0755 exactly once`` () = + let source = "module M\n[]\nlet a, b, c = 1, 2, 3" + let result = + FSharp source + |> typecheck + |> shouldFail + + let diag755Count = + result.Output.Diagnostics + |> List.filter (fun d -> d.Error = Error 755) + |> List.length + Assert.Equal(1, diag755Count) + + [] + let ``CompiledName on single-value let-binding still compiles`` () = + FSharp "module M\n[]\nlet a = 1" + |> compile + |> shouldSucceed + |> withWarnings [] + |> ignore + + [] + [] + [] + [] + let ``Multi-value let-binding without CompiledName still compiles`` (source: string) = + FSharp source + |> compile + |> shouldSucceed + |> withWarnings [] + |> ignore + + [] + []\nlet (Some x) = Some 1")>] + []\nlet (Box x) = Box 1")>] + []\nlet a, _ = 1, 2")>] + []\nlet { F = a } = { F = 1; G = 2 }")>] + []\nlet [| a |] = [| 1 |]")>] + []\nlet a :: _ = [1; 2]")>] + []\nlet (|Even|Odd|) n = if n % 2 = 0 then Even else Odd")>] + let ``CompiledName on single-value destructure does not fire FS0755`` (source: string) = + let result = FSharp source |> typecheck + let diags = + match result with + | CompilationResult.Success r -> r.Diagnostics + | CompilationResult.Failure r -> r.Diagnostics + let fs755 = diags |> List.filter (fun d -> d.Error = Error 755) + Assert.Empty(fs755) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOff.il.bsl index 1683f66f50e..ab736a3c457 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOff.il.bsl @@ -50,28 +50,29 @@ } - .method assembly specialname static int32 get_outArg@8() cil managed + .method assembly specialname static class [runtime]System.Tuple`2 get_patternInput@8() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$OutOptionalTests::outArg@8 + IL_0000: ldsfld class [runtime]System.Tuple`2 ''.$OutOptionalTests::patternInput@8 IL_0005: ret } - .method assembly specialname static int32 'get_outArg@9-1'() cil managed + .method assembly specialname static int32 get_outArg@8() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$OutOptionalTests::'outArg@9-1' + IL_0000: ldsfld int32 ''.$OutOptionalTests::outArg@8 IL_0005: ret } - .method assembly specialname static class [runtime]System.Tuple`2 get_patternInput@8() cil managed + .method assembly specialname static void set_outArg@8(int32 'value') cil managed { .maxstack 8 - IL_0000: ldsfld class [runtime]System.Tuple`2 ''.$OutOptionalTests::patternInput@8 - IL_0005: ret + IL_0000: ldarg.0 + IL_0001: stsfld int32 ''.$OutOptionalTests::outArg@8 + IL_0006: ret } .method assembly specialname static class [runtime]System.Tuple`2 'get_patternInput@9-1'() cil managed @@ -82,13 +83,12 @@ IL_0005: ret } - .method assembly specialname static void set_outArg@8(int32 'value') cil managed + .method assembly specialname static int32 'get_outArg@9-1'() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld int32 ''.$OutOptionalTests::outArg@8 - IL_0006: ret + IL_0000: ldsfld int32 ''.$OutOptionalTests::'outArg@9-1' + IL_0005: ret } .method assembly specialname static void 'set_outArg@9-1'(int32 'value') cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOn.il.bsl index ccdd1726cac..320273baa2d 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/MethodResolution/OptionalAndOutParameters.fs.RealInternalSignatureOn.il.bsl @@ -58,15 +58,12 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly int32 'outArg@9-1' .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed + .method assembly specialname static class [runtime]System.Tuple`2 get_patternInput@8() cil managed { .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$OutOptionalTests::init@ - IL_0006: ldsfld int32 ''.$OutOptionalTests::init@ - IL_000b: pop - IL_000c: ret + IL_0000: ldsfld class [runtime]System.Tuple`2 OutOptionalTests::patternInput@8 + IL_0005: ret } .method assembly specialname static int32 get_outArg@8() cil managed @@ -77,46 +74,49 @@ IL_0005: ret } - .method assembly specialname static int32 'get_outArg@9-1'() cil managed + .method assembly specialname static void set_outArg@8(int32 'value') cil managed { .maxstack 8 - IL_0000: ldsfld int32 OutOptionalTests::'outArg@9-1' - IL_0005: ret + IL_0000: ldarg.0 + IL_0001: stsfld int32 OutOptionalTests::outArg@8 + IL_0006: ret } - .method assembly specialname static class [runtime]System.Tuple`2 get_patternInput@8() cil managed + .method assembly specialname static class [runtime]System.Tuple`2 'get_patternInput@9-1'() cil managed { .maxstack 8 - IL_0000: ldsfld class [runtime]System.Tuple`2 OutOptionalTests::patternInput@8 + IL_0000: ldsfld class [runtime]System.Tuple`2 OutOptionalTests::'patternInput@9-1' IL_0005: ret } - .method assembly specialname static class [runtime]System.Tuple`2 'get_patternInput@9-1'() cil managed + .method assembly specialname static int32 'get_outArg@9-1'() cil managed { .maxstack 8 - IL_0000: ldsfld class [runtime]System.Tuple`2 OutOptionalTests::'patternInput@9-1' + IL_0000: ldsfld int32 OutOptionalTests::'outArg@9-1' IL_0005: ret } - .method assembly specialname static void set_outArg@8(int32 'value') cil managed + .method assembly specialname static void 'set_outArg@9-1'(int32 'value') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: stsfld int32 OutOptionalTests::outArg@8 + IL_0001: stsfld int32 OutOptionalTests::'outArg@9-1' IL_0006: ret } - .method assembly specialname static void 'set_outArg@9-1'(int32 'value') cil managed + .method private specialname rtspecialname static void .cctor() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld int32 OutOptionalTests::'outArg@9-1' - IL_0006: ret + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$OutOptionalTests::init@ + IL_0006: ldsfld int32 ''.$OutOptionalTests::init@ + IL_000b: pop + IL_000c: ret } .method assembly static void staticInitialization@() cil managed @@ -198,3 +198,4 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest1.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest1.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 6d7bb25f2c0..bf8d61c2c81 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest1.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest1.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -118,17 +118,6 @@ IL_0011: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -145,6 +134,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest2.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest2.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index f30163e4e6e..db8466927b3 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest2.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest2.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -180,17 +180,6 @@ IL_0019: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -207,6 +196,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest3.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest3.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 0bf0bc68cf7..3fd6bffac1f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest3.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest3.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -149,17 +149,6 @@ IL_0011: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -176,6 +165,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest4.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest4.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index b09bee355e6..d6e821f237c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest4.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest4.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -280,17 +280,6 @@ IL_0011: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -307,6 +296,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest5.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest5.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index f6eab7c7c48..f026a2496bd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest5.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest5.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -345,17 +345,6 @@ IL_0011: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -372,6 +361,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest6.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest6.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 82a74f660af..15cf80f9313 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest6.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/AsyncExpressionStepping/AsyncExpressionSteppingTest6.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -607,17 +607,6 @@ IL_0011: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1 get_arg@1() cil managed { @@ -634,6 +623,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Accessibility 11.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Accessibility 11.bsl index 539f2942ff6..7bc7054a65f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Accessibility 11.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Accessibility 11.bsl @@ -78,6 +78,15 @@ T::.cctor IL_000b: pop IL_000c: ret +T::staticInitialization@ + (5,12-5,21) let i = 1 + IL_0000: ldc.i4.1 + IL_0001: stsfld T::i + IL_0006: ldc.i4.1 + IL_0007: volatile. + IL_0009: stsfld T::init@4 + IL_000e: ret + T::__debug@7 (6,58-6,59) i IL_0000: volatile. @@ -97,12 +106,3 @@ T::__debug@7 IL_0013: nop IL_0014: ldsfld T::i IL_0019: ret - -T::staticInitialization@ - (5,12-5,21) let i = 1 - IL_0000: ldc.i4.1 - IL_0001: stsfld T::i - IL_0006: ldc.i4.1 - IL_0007: volatile. - IL_0009: stsfld T::init@4 - IL_000e: ret diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 14.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 14.bsl index e1fd2983ee7..38f4791daf0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 14.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 14.bsl @@ -33,14 +33,6 @@ Test::g$W IL_000d: add IL_000e: ret -Test::.cctor - - IL_0000: ldc.i4.0 - IL_0001: stsfld $Test::init@ - IL_0006: ldsfld $Test::init@ - IL_000b: pop - IL_000c: ret - Test::__debug@7 (5,32-5,41) f (x + y) IL_0000: ldarg.0 @@ -50,6 +42,14 @@ Test::__debug@7 IL_0004: add IL_0005: ret +Test::.cctor + + IL_0000: ldc.i4.0 + IL_0001: stsfld $Test::init@ + IL_0006: ldsfld $Test::init@ + IL_000b: pop + IL_000c: ret + Test::staticInitialization@ (7,1-7,6) g 1 2 IL_0000: ldc.i4.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 15.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 15.bsl index 383930edbe7..3b60f224c31 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 15.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/Call 15.bsl @@ -31,6 +31,13 @@ Test::g$W IL_0009: call InvokeFast IL_000e: ret +Test::__debug@7 + (5,32-5,41) f (x + y) + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + Test::.cctor IL_0000: ldc.i4.0 @@ -39,13 +46,6 @@ Test::.cctor IL_000b: pop IL_000c: ret -Test::__debug@7 - (5,32-5,41) f (x + y) - IL_0000: ldarg.0 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - Test::staticInitialization@ (7,1-7,6) g 1 2 IL_0000: ldc.i4.1 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/SRTP 22 - Recursive inline with different type arg.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/SRTP 22 - Recursive inline with different type arg.bsl index 2c90e1376e9..22632af1c65 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/SRTP 22 - Recursive inline with different type arg.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/DebugInlineAsCall/SRTP 22 - Recursive inline with different type arg.bsl @@ -63,22 +63,22 @@ Test::main IL_0015: ldc.i4.1 IL_0016: ret -Test::__debug@13 +Test::__debug@9-1 (6,36-6,69) (T $ Unchecked.defaultof<'r>) i x IL_0000: call T::get_T - IL_0005: ldnull - IL_0006: call Test::__debug@6 + IL_0005: ldc.i4.0 + IL_0006: call T::op_Dollar IL_000b: ldarg.0 IL_000c: ldarg.1 IL_000d: tail. IL_000f: call InvokeFast IL_0014: ret -Test::__debug@9-1 +Test::__debug@13 (6,36-6,69) (T $ Unchecked.defaultof<'r>) i x IL_0000: call T::get_T - IL_0005: ldc.i4.0 - IL_0006: call T::op_Dollar + IL_0005: ldnull + IL_0006: call Test::__debug@6 IL_000b: ldarg.0 IL_000c: ldarg.1 IL_000d: tail. diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOff.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOff.OptimizeOn.il.bsl index f36dd09ddc2..45d30e4a1c6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOff.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOff.OptimizeOn.il.bsl @@ -57,6 +57,15 @@ IL_0005: ret } + .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$assembly::current@9 + IL_0006: ret + } + .method assembly specialname static int32 get_e1@1() cil managed { @@ -81,15 +90,6 @@ IL_0005: ret } - .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$assembly::current@9 - IL_0006: ret - } - .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 9c4aabc28ab..9f4931ff9f7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd03.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -61,23 +61,21 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_current@9() cil managed { .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_current@9() cil managed + .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 - IL_0005: ret + IL_0000: ldarg.0 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0006: ret } .method assembly specialname static int32 get_e1@1() cil managed @@ -104,22 +102,24 @@ IL_0005: ret } - .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::next@9 IL_0006: ret } - .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + .method private specialname rtspecialname static void .cctor() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::next@9 - IL_0006: ret + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret } .method assembly static void staticInitialization@() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOff.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOff.OptimizeOn.il.bsl index 894f3c82c64..78bc9fe4342 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOff.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOff.OptimizeOn.il.bsl @@ -57,6 +57,15 @@ IL_0005: ret } + .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$assembly::current@9 + IL_0006: ret + } + .method assembly specialname static int32 get_e1@1() cil managed { @@ -81,15 +90,6 @@ IL_0005: ret } - .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 ''.$assembly::current@9 - IL_0006: ret - } - .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index e5f244aa9c5..e9ee8964726 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ForLoop/NonTrivialBranchingBindingInEnd04.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -61,23 +61,21 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_current@9() cil managed { .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_current@9() cil managed + .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 - IL_0005: ret + IL_0000: ldarg.0 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0006: ret } .method assembly specialname static int32 get_e1@1() cil managed @@ -104,22 +102,24 @@ IL_0005: ret } - .method assembly specialname static void set_current@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed { .maxstack 8 IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::current@9 + IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::next@9 IL_0006: ret } - .method assembly specialname static void set_next@9(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'value') cil managed + .method private specialname rtspecialname static void .cctor() cil managed { .maxstack 8 - IL_0000: ldarg.0 - IL_0001: stsfld class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 assembly::next@9 - IL_0006: ret + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret } .method assembly static void staticInitialization@() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.net472.bsl index b477f2b4bbd..1d15587c215 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.net472.bsl @@ -357,17 +357,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeStruct y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -392,6 +381,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.netcore.bsl index b477f2b4bbd..1d15587c215 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals10.fsx.il.netcore.bsl @@ -357,17 +357,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeStruct y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -392,6 +381,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.net472.bsl index cd28d924687..abaef1b1e97 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.net472.bsl @@ -447,17 +447,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeUnion y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -482,6 +471,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.netcore.bsl index 04815c3b085..00bdf966b88 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals11.fsx.il.netcore.bsl @@ -447,17 +447,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeUnion y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -482,6 +471,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.net472.bsl index 35dabf683a1..526f62b1351 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.net472.bsl @@ -391,17 +391,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeRecord y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -426,6 +415,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.netcore.bsl index 05bef0acdff..3417bbfd3bc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals12.fsx.il.netcore.bsl @@ -391,17 +391,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeRecord y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -426,6 +415,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.net472.bsl index 83c1fd826cf..8daa2678cb6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.net472.bsl @@ -383,17 +383,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericStruct`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -418,6 +407,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.netcore.bsl index 83c1fd826cf..8daa2678cb6 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals13.fsx.il.netcore.bsl @@ -383,17 +383,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericStruct`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -418,6 +407,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.net472.bsl index cd307b9c5e0..c8d6dbb2dfd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.net472.bsl @@ -473,17 +473,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericUnion`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -508,6 +497,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.netcore.bsl index cf8480c58d1..541e25c5210 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals14.fsx.il.netcore.bsl @@ -473,17 +473,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericUnion`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -508,6 +497,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.net472.bsl index fa25aa1ed62..33d45fc8bbd 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.net472.bsl @@ -417,17 +417,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericRecord`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -452,6 +441,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.netcore.bsl index a30b4b70858..38b3610d0c2 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals15.fsx.il.netcore.bsl @@ -417,17 +417,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeGenericRecord`1 y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -452,6 +441,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.net472.bsl index 3e84fe0b1a5..4d34d84ee61 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.net472.bsl @@ -357,17 +357,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeStruct y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -392,6 +381,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.netcore.bsl index 3e84fe0b1a5..4d34d84ee61 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals16.fsx.il.netcore.bsl @@ -357,17 +357,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeStruct y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -392,6 +381,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.net472.bsl index bdc06c093a2..28852e8defc 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.net472.bsl @@ -447,17 +447,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeUnion y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -482,6 +471,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.netcore.bsl index c09916f96f8..3004404175c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals17.fsx.il.netcore.bsl @@ -447,17 +447,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeUnion y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -482,6 +471,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.net472.bsl index ddf69384863..cbcf2f71bad 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.net472.bsl @@ -391,17 +391,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeRecord y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -426,6 +415,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.netcore.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.netcore.bsl index 692d6c3c424..a40baefd7b8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.netcore.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals18.fsx.il.netcore.bsl @@ -391,17 +391,6 @@ .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) .field static assembly valuetype assembly/EqualsMicroPerfAndCodeGenerationTests/SomeRecord y@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_arg@1() cil managed { @@ -426,6 +415,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/AugmentationClosureNesting.fs.RealInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/AugmentationClosureNesting.fs.RealInternalSignatureOn.il.bsl index 2e61311286a..04b8d498e76 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/AugmentationClosureNesting.fs.RealInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Inlining/AugmentationClosureNesting.fs.RealInternalSignatureOn.il.bsl @@ -146,6 +146,18 @@ IL_000c: ret } + .method assembly static void staticInitialization@() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 Sample/C::backing + IL_0006: ldc.i4.1 + IL_0007: volatile. + IL_0009: stsfld int32 Sample/C::init@2 + IL_000e: ret + } + .method public hidebysig instance int32 Run() cil managed { @@ -160,18 +172,6 @@ IL_000f: ret } - .method assembly static void staticInitialization@() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 Sample/C::backing - IL_0006: ldc.i4.1 - IL_0007: volatile. - IL_0009: stsfld int32 Sample/C::init@2 - IL_000e: ret - } - } .method public static int32 main(string[] _arg1) cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.net472.bsl index af11ac26847..50435594d2d 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/AnonRecd.fs.il.net472.bsl @@ -16,16 +16,6 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 -} -.mresource public FSharpSignatureCompressedData.assembly -{ - - -} -.mresource public FSharpOptimizationCompressedData.assembly -{ - - } .module assembly.exe @@ -90,9 +80,7 @@ .field private !'j__TPar' B@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .method public specialname rtspecialname - instance void .ctor(!'j__TPar' A, - !'j__TPar' B) cil managed + .method public specialname rtspecialname instance void .ctor(!'j__TPar' A, !'j__TPar' B) cil managed { .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes, class [runtime]System.Type) = ( 01 00 60 06 00 00 1E 3C 3E 66 5F 5F 41 6E 6F 6E @@ -218,9 +206,7 @@ IL_000e: ret } - .method public hidebysig virtual final - instance int32 CompareTo(object obj, - class [runtime]System.Collections.IComparer comp) cil managed + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -350,9 +336,7 @@ IL_000d: ret } - .method public hidebysig instance bool - Equals(class '<>f__AnonymousType1912756633`2'j__TPar',!'j__TPar'> obj, - class [runtime]System.Collections.IEqualityComparer comp) cil managed + .method public hidebysig instance bool Equals(class '<>f__AnonymousType1912756633`2'j__TPar',!'j__TPar'> obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -401,9 +385,7 @@ IL_003c: ret } - .method public hidebysig virtual final - instance bool Equals(object obj, - class [runtime]System.Collections.IEqualityComparer comp) cil managed + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -540,9 +522,7 @@ .field private class [runtime]System.Type Type@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public specialname rtspecialname - instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, - class [runtime]System.Type Type) cil managed + .method public specialname rtspecialname instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, class [runtime]System.Type Type) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl index 3ec0bb3490d..deb49d2adb1 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl @@ -291,75 +291,75 @@ IL_0005: ret } - .method assembly specialname static int32 'get_arg_0@34-1'() cil managed + .method assembly specialname static int32 get_arg_1@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_0@34-1' + IL_0000: ldsfld int32 ''.$assembly::arg_1@30 IL_0005: ret } - .method assembly specialname static int32 'get_arg_0@38-2'() cil managed + .method assembly specialname static int32 get_arg_2@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_0@38-2' + IL_0000: ldsfld int32 ''.$assembly::arg_2@30 IL_0005: ret } - .method assembly specialname static int32 get_arg_1@30() cil managed + .method assembly specialname static int32 get_arg_3@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::arg_1@30 + IL_0000: ldsfld int32 ''.$assembly::arg_3@30 IL_0005: ret } - .method assembly specialname static int32 'get_arg_1@34-1'() cil managed + .method assembly specialname static int32 'get_arg_0@34-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_1@34-1' + IL_0000: ldsfld int32 ''.$assembly::'arg_0@34-1' IL_0005: ret } - .method assembly specialname static int32 'get_arg_1@38-2'() cil managed + .method assembly specialname static int32 'get_arg_1@34-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_1@38-2' + IL_0000: ldsfld int32 ''.$assembly::'arg_1@34-1' IL_0005: ret } - .method assembly specialname static int32 get_arg_2@30() cil managed + .method assembly specialname static int32 'get_arg_2@34-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::arg_2@30 + IL_0000: ldsfld int32 ''.$assembly::'arg_2@34-1' IL_0005: ret } - .method assembly specialname static int32 'get_arg_2@34-1'() cil managed + .method assembly specialname static int32 'get_arg_0@38-2'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_2@34-1' + IL_0000: ldsfld int32 ''.$assembly::'arg_0@38-2' IL_0005: ret } - .method assembly specialname static int32 'get_arg_2@38-2'() cil managed + .method assembly specialname static int32 'get_arg_1@38-2'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::'arg_2@38-2' + IL_0000: ldsfld int32 ''.$assembly::'arg_1@38-2' IL_0005: ret } - .method assembly specialname static int32 get_arg_3@30() cil managed + .method assembly specialname static int32 'get_arg_2@38-2'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 ''.$assembly::arg_3@30 + IL_0000: ldsfld int32 ''.$assembly::'arg_2@38-2' IL_0005: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index a0c07c33e9b..c8843431ed9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/CodeGenRenamings01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -327,46 +327,43 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed + .method assembly specialname static int32 get_arg_0@30() cil managed { .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret + IL_0000: ldsfld int32 assembly::arg_0@30 + IL_0005: ret } - .method assembly specialname static int32 get_arg_0@30() cil managed + .method assembly specialname static int32 get_arg_1@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::arg_0@30 + IL_0000: ldsfld int32 assembly::arg_1@30 IL_0005: ret } - .method assembly specialname static int32 'get_arg_0@34-1'() cil managed + .method assembly specialname static int32 get_arg_2@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::'arg_0@34-1' + IL_0000: ldsfld int32 assembly::arg_2@30 IL_0005: ret } - .method assembly specialname static int32 'get_arg_0@38-2'() cil managed + .method assembly specialname static int32 get_arg_3@30() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::'arg_0@38-2' + IL_0000: ldsfld int32 assembly::arg_3@30 IL_0005: ret } - .method assembly specialname static int32 get_arg_1@30() cil managed + .method assembly specialname static int32 'get_arg_0@34-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::arg_1@30 + IL_0000: ldsfld int32 assembly::'arg_0@34-1' IL_0005: ret } @@ -378,27 +375,27 @@ IL_0005: ret } - .method assembly specialname static int32 'get_arg_1@38-2'() cil managed + .method assembly specialname static int32 'get_arg_2@34-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::'arg_1@38-2' + IL_0000: ldsfld int32 assembly::'arg_2@34-1' IL_0005: ret } - .method assembly specialname static int32 get_arg_2@30() cil managed + .method assembly specialname static int32 'get_arg_0@38-2'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::arg_2@30 + IL_0000: ldsfld int32 assembly::'arg_0@38-2' IL_0005: ret } - .method assembly specialname static int32 'get_arg_2@34-1'() cil managed + .method assembly specialname static int32 'get_arg_1@38-2'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::'arg_2@34-1' + IL_0000: ldsfld int32 assembly::'arg_1@38-2' IL_0005: ret } @@ -410,20 +407,23 @@ IL_0005: ret } - .method assembly specialname static int32 get_arg_3@30() cil managed + .method assembly specialname static int32 'get_arg_3@38-1'() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::arg_3@30 + IL_0000: ldsfld int32 assembly::'arg_3@38-1' IL_0005: ret } - .method assembly specialname static int32 'get_arg_3@38-1'() cil managed + .method private specialname rtspecialname static void .cctor() cil managed { .maxstack 8 - IL_0000: ldsfld int32 assembly::'arg_3@38-1' - IL_0005: ret + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret } .method assembly static void staticInitialization@() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/LetIfThenElse01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/LetIfThenElse01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 0097c30b164..2df0d35533a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/LetIfThenElse01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/LetIfThenElse01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -157,6 +157,14 @@ IL_00b4: ret } + .method assembly specialname static class [runtime]System.Tuple`4 get_arg@1() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [runtime]System.Tuple`4 assembly::arg@1 + IL_0005: ret + } + .method private specialname rtspecialname static void .cctor() cil managed { @@ -168,14 +176,6 @@ IL_000c: ret } - .method assembly specialname static class [runtime]System.Tuple`4 get_arg@1() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [runtime]System.Tuple`4 assembly::arg@1 - IL_0005: ret - } - .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/Lock01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/Lock01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 9b64b730953..9c646debced 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/Lock01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/Lock01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -50,17 +50,6 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly::init@ - IL_0006: ldsfld int32 ''.$assembly::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static bool get_lockTaken@1() cil managed { @@ -78,6 +67,17 @@ IL_0006: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly::init@ + IL_0006: ldsfld int32 ''.$assembly::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl index abf97003994..7a83b1d3f19 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOff.OptimizeOn.il.bsl @@ -42,22 +42,22 @@ extends [runtime]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 specialname static int32 get_x() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 get_format@1() cil managed { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ret + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 ''.$assembly::format@1 + IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 get_format@1() cil managed + .method public specialname static int32 get_x() cil managed { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 ''.$assembly::format@1 - IL_0005: ret + IL_0000: ldc.i4.1 + IL_0001: ret } .property class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 66772bf729a..48c47f52b7c 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Misc/ModuleWithExpression01.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -44,6 +44,14 @@ .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 ) .field static assembly class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 format@1 .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 get_format@1() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 assembly/M::format@1 + IL_0005: ret + } + .method public specialname static int32 get_x() cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -65,14 +73,6 @@ IL_000c: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 get_format@1() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 assembly/M::format@1 - IL_0005: ret - } - .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl index 23409788a03..95625985eee 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/Nullness/AnonRecords.fs.il.net472.bsl @@ -373,9 +373,7 @@ IL_000e: ret } - .method public hidebysig virtual final - instance int32 CompareTo(object obj, - class [runtime]System.Collections.IComparer comp) cil managed + .method public hidebysig virtual final instance int32 CompareTo(object obj, class [runtime]System.Collections.IComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .param [1] @@ -547,9 +545,7 @@ IL_000d: ret } - .method public hidebysig instance bool - Equals(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj, - class [runtime]System.Collections.IEqualityComparer comp) cil managed + .method public hidebysig instance bool Equals(class '<>f__AnonymousType2430756162`3'j__TPar',!'j__TPar',!'j__TPar'> obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -611,9 +607,7 @@ IL_0052: ret } - .method public hidebysig virtual final - instance bool Equals(object obj, - class [runtime]System.Collections.IEqualityComparer comp) cil managed + .method public hidebysig virtual final instance bool Equals(object obj, class [runtime]System.Collections.IEqualityComparer comp) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .param [1] @@ -771,9 +765,7 @@ .field private class [runtime]System.Type Type@ .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method public specialname rtspecialname - instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, - class [runtime]System.Type Type) cil managed + .method public specialname rtspecialname instance void .ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes MemberType, class [runtime]System.Type Type) cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction23.fs.RealInternalSignatureOn.OptimizeOn.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction23.fs.RealInternalSignatureOn.OptimizeOn.il.net472.bsl index 43b4d63535e..a6e2769acb9 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction23.fs.RealInternalSignatureOn.OptimizeOn.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction23.fs.RealInternalSignatureOn.OptimizeOn.il.net472.bsl @@ -1,21 +1,26 @@ + + + + + .assembly extern runtime { } .assembly extern FSharp.Core { } .assembly extern netstandard { -.publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) -.ver 2:1:0:0 + .publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) + .ver 2:1:0:0 } .assembly assembly { -.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 ) - - + .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 ) + + -.hash algorithm 0x00008004 -.ver 0:0:0:0 + .hash algorithm 0x00008004 + .ver 0:0:0:0 } .module assembly.exe @@ -30,109 +35,115 @@ int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) .class public abstract auto ansi sealed assembly -extends [runtime]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 ) -.class auto ansi serializable nested public C -extends [runtime]System.Object -{ -.custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) -.field assembly string x -.field assembly string x@8 -.method public specialname rtspecialname instance void .ctor() cil managed + extends [runtime]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 ) + .class auto ansi serializable nested public C + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 03 00 00 00 00 00 ) + .field assembly string x + .field assembly string x@8 + .method public specialname rtspecialname instance void .ctor() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: callvirt instance void [runtime]System.Object::.ctor() + IL_0006: ldarg.0 + IL_0007: pop + IL_0008: ldarg.0 + IL_0009: call string [runtime]System.Console::ReadLine() + IL_000e: stfld string assembly/C::x + IL_0013: ldarg.0 + IL_0014: call string [runtime]System.Console::ReadLine() + IL_0019: stfld string assembly/C::x@8 + IL_001e: ret + } + + .method public hidebysig instance string M() cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string assembly/C::x@8 + IL_0006: ldarg.0 + IL_0007: callvirt instance string assembly/C::g() + IL_000c: call string [runtime]System.String::Concat(string, + string) + IL_0011: ret + } + + .method assembly hidebysig instance string g() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld string assembly/C::x + IL_0006: ret + } + + } + + .method public static class [runtime]System.Tuple`2 f(!!a x) cil managed + { + + .maxstack 8 + IL_0000: ldnull + IL_0001: call void assembly::g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_0006: nop + IL_0007: ldnull + IL_0008: ldnull + IL_0009: call void assembly::g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit) + IL_000e: nop + IL_000f: ldnull + IL_0010: newobj instance void class [runtime]System.Tuple`2::.ctor(!0, + !1) + IL_0015: ret + } + + .method assembly static void g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar0) cil managed + { + + .maxstack 4 + .locals init (class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_0) + IL_0000: ldstr "Hello" + IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_000a: stloc.0 + IL_000b: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_0010: ldloc.0 + IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_0016: pop + IL_0017: ldstr "Hello" + IL_001c: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) + IL_0021: stloc.0 + IL_0022: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() + IL_0027: ldloc.0 + IL_0028: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, + class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) + IL_002d: pop + IL_002e: ret + } -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: callvirt instance void [runtime]System.Object::.ctor() -IL_0006: ldarg.0 -IL_0007: pop -IL_0008: ldarg.0 -IL_0009: call string [runtime]System.Console::ReadLine() -IL_000e: stfld string assembly/C::x -IL_0013: ldarg.0 -IL_0014: call string [runtime]System.Console::ReadLine() -IL_0019: stfld string assembly/C::x@8 -IL_001e: ret } -.method public hidebysig instance string M() cil managed -{ - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ldfld string assembly/C::x@8 -IL_0006: ldarg.0 -IL_0007: callvirt instance string assembly/C::g() -IL_000c: call string [runtime]System.String::Concat(string, -string) -IL_0011: ret -} - -.method assembly hidebysig instance string g() cil managed -{ -.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - -.maxstack 8 -IL_0000: ldarg.0 -IL_0001: ldfld string assembly/C::x -IL_0006: ret -} - -} - -.method public static class [runtime]System.Tuple`2 f(!!a x) cil managed +.class private abstract auto ansi sealed ''.$assembly + extends [runtime]System.Object { + .method public static void main@() cil managed + { + .entrypoint + + .maxstack 8 + IL_0000: ret + } -.maxstack 8 -IL_0000: ldnull -IL_0001: call void assembly::g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit) -IL_0006: nop -IL_0007: ldnull -IL_0008: ldnull -IL_0009: call void assembly::g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit) -IL_000e: nop -IL_000f: ldnull -IL_0010: newobj instance void class [runtime]System.Tuple`2::.ctor(!0, -!1) -IL_0015: ret } -.method assembly static void g@12(class [FSharp.Core]Microsoft.FSharp.Core.Unit unitVar0) cil managed -{ -.maxstack 4 -.locals init (class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4 V_0) -IL_0000: ldstr "Hello" -IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) -IL_000a: stloc.0 -IL_000b: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() -IL_0010: ldloc.0 -IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, -class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) -IL_0016: pop -IL_0017: ldstr "Hello" -IL_001c: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5::.ctor(string) -IL_0021: stloc.0 -IL_0022: call class [netstandard]System.IO.TextWriter [netstandard]System.Console::get_Out() -IL_0027: ldloc.0 -IL_0028: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(class [runtime]System.IO.TextWriter, -class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4) -IL_002d: pop -IL_002e: ret -} -} -.class private abstract auto ansi sealed ''.$assembly -extends [runtime]System.Object -{ -.method public static void main@() cil managed -{ -.entrypoint -.maxstack 8 -IL_0000: ret -} -} \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOff.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOff.OptimizeOn.il.bsl index 14988831b07..6ec0bc58182 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOff.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOff.OptimizeOn.il.bsl @@ -166,6 +166,14 @@ IL_0005: ret } + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> get_format@1() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::format@1 + IL_0005: ret + } + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_functionResult() cil managed { @@ -174,7 +182,15 @@ IL_0005: ret } - .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'f@26-1'(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 _arg1) cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> 'get_format@1-1'() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::'format@1-1' + IL_0005: ret + } + + .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f@7(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 l) cil managed { .maxstack 4 @@ -205,7 +221,7 @@ IL_0029: ldarg.0 IL_002a: ldloc.1 - IL_002b: starg.s _arg1 + IL_002b: starg.s l IL_002d: starg.s condition IL_002f: br.s IL_0000 @@ -216,7 +232,7 @@ IL_0038: ret } - .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f@7(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 l) cil managed + .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'f@26-1'(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 _arg1) cil managed { .maxstack 4 @@ -247,7 +263,7 @@ IL_0029: ldarg.0 IL_002a: ldloc.1 - IL_002b: starg.s l + IL_002b: starg.s _arg1 IL_002d: starg.s condition IL_002f: br.s IL_0000 @@ -258,22 +274,6 @@ IL_0038: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> get_format@1() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::format@1 - IL_0005: ret - } - - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> 'get_format@1-1'() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::'format@1-1' - IL_0005: ret - } - .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list() { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOn.OptimizeOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOn.OptimizeOn.il.bsl index 14988831b07..6ec0bc58182 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOn.OptimizeOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/Verify13043.fs.RealInternalSignatureOn.OptimizeOn.il.bsl @@ -166,6 +166,14 @@ IL_0005: ret } + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> get_format@1() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::format@1 + IL_0005: ret + } + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 get_functionResult() cil managed { @@ -174,7 +182,15 @@ IL_0005: ret } - .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'f@26-1'(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 _arg1) cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> 'get_format@1-1'() cil managed + { + + .maxstack 8 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::'format@1-1' + IL_0005: ret + } + + .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f@7(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 l) cil managed { .maxstack 4 @@ -205,7 +221,7 @@ IL_0029: ldarg.0 IL_002a: ldloc.1 - IL_002b: starg.s _arg1 + IL_002b: starg.s l IL_002d: starg.s condition IL_002f: br.s IL_0000 @@ -216,7 +232,7 @@ IL_0038: ret } - .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f@7(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 l) cil managed + .method assembly static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 'f@26-1'(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 condition, class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 _arg1) cil managed { .maxstack 4 @@ -247,7 +263,7 @@ IL_0029: ldarg.0 IL_002a: ldloc.1 - IL_002b: starg.s l + IL_002b: starg.s _arg1 IL_002d: starg.s condition IL_002f: br.s IL_0000 @@ -258,22 +274,6 @@ IL_0038: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> get_format@1() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::format@1 - IL_0005: ret - } - - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> 'get_format@1-1'() cil managed - { - - .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4,class [FSharp.Core]Microsoft.FSharp.Core.Unit>,class [runtime]System.IO.TextWriter,class [FSharp.Core]Microsoft.FSharp.Core.Unit,class [FSharp.Core]Microsoft.FSharp.Core.Unit> ''.$assembly::'format@1-1' - IL_0005: ret - } - .property class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list() { diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 0908b6600ea..5070905529f 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -279,6 +279,7 @@ + @@ -516,6 +517,7 @@ + diff --git a/tests/FSharp.Compiler.ComponentTests/Optimizations/TaskCEUnitPropertyAccess.fs b/tests/FSharp.Compiler.ComponentTests/Optimizations/TaskCEUnitPropertyAccess.fs new file mode 100644 index 00000000000..e100f12501f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Optimizations/TaskCEUnitPropertyAccess.fs @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Optimizations + +open Xunit +open FSharp.Test.Compiler + +// Regression tests for https://github.com/dotnet/fsharp/issues/13099 +// State machine lowering dropped an unused `let this = receiver in ()` binding, discarding the +// receiver's side effect. Each test compiles under Debug and Release and asserts it is observed. +// Snippets run in-process via reflection, so use `failwith` (not `exit`) to signal failure. +module TaskCEUnitPropertyAccess = + + let private run (optimize: bool) (source: string) = + Fsx source + |> asExe + |> withOptimization optimize + |> compileExeAndRun + |> shouldSucceed + |> ignore + + [] // Debug + [] // Release + [] + let ``TaskCE_UnitPropertyAccess_PreservesReceiverSideEffects`` (optimize: bool) = + run optimize """ +type SomeOutputType() = + member x.End = () + +let someFunctionWithReturnType () = + failwith "This should be raised" + SomeOutputType() + +let theTaskAtHand () = + task { (someFunctionWithReturnType ()).End } + +try + theTaskAtHand().Wait() + failwith "Expected exception was not raised; the optimizer dropped the side-effectful receiver." +with +| :? System.AggregateException as ex when ex.InnerException.Message = "This should be raised" -> () +""" + + [] + [] + [] + let ``UnitPropertyAccess_OnSideEffectfulReceiver_OutsideTaskCE_Raises`` (optimize: bool) = + run optimize """ +type SomeOutputType() = + member x.End = () + +let someFunctionWithReturnType () = + failwith "boom" + SomeOutputType() + +let test () = (someFunctionWithReturnType ()).End + +try + test () + failwith "Expected exception was not raised; the optimizer dropped the side-effectful receiver." +with +| ex when ex.Message = "boom" -> () +""" + + [] + [] + [] + let ``TaskCE_UnitMethodCall_PreservesReceiverSideEffects`` (optimize: bool) = + run optimize """ +type SomeOutputType() = + member x.Finish() = () + +let someFunctionWithReturnType () = + failwith "boom" + SomeOutputType() + +let theTaskAtHand () = + task { (someFunctionWithReturnType ()).Finish() } + +try + theTaskAtHand().Wait() + failwith "Expected exception was not raised; the optimizer dropped the side-effectful receiver." +with +| :? System.AggregateException as ex when ex.InnerException.Message = "boom" -> () +""" + + [] + [] + [] + let ``TaskCE_UnitPropertyAccess_RunsBothReceiverAndGetterEffects`` (optimize: bool) = + run optimize """ +let mutable counter = 0 + +type Tracker() = + member x.Done = counter <- counter + 1 + +let makeTracker () = + counter <- counter + 1 + Tracker() + +let theTaskAtHand () = + task { (makeTracker ()).Done } + +theTaskAtHand().Wait() +if counter <> 2 then + failwithf "Expected counter=2 (receiver + getter side effects) but got %d" counter +""" + + [] + [] + [] + let ``TaskCE_NonUnitPropertyAccess_OnSideEffectfulReceiver_Raises`` (optimize: bool) = + run optimize """ +type HasValue() = + member x.Value = 42 + +let makeHasValue () = + failwith "boom" + HasValue() + +let theTaskAtHand () = + task { let _ = (makeHasValue ()).Value in () } + +try + theTaskAtHand().Wait() + failwith "Expected exception was not raised." +with +| :? System.AggregateException as ex when ex.InnerException.Message = "boom" -> () +""" + + [] + [] + [] + let ``TaskCE_StructProjectionUnitAccess_PreservesReceiverSideEffects`` (optimize: bool) = + run optimize """ +#nowarn "52" +type Inner() = + member _.End = () + +[] +type Outer = + val Inner: Inner + new(i) = { Inner = i } + member x.GetInner = x.Inner + +let makeOuter () = + failwith "boom" + Outer(Inner()) + +let theTaskAtHand () = + task { (makeOuter()).GetInner.End } + +try + theTaskAtHand().Wait() + failwith "Expected exception was not raised; the receiver side effect was dropped." +with +| :? System.AggregateException as ex when ex.InnerException.Message = "boom" -> () +""" + + [] + [] + [] + let ``AsyncCE_UnitPropertyAccess_PreservesReceiverSideEffects`` (optimize: bool) = + run optimize """ +type SomeOutputType() = + member x.End = () + +let someFunctionWithReturnType () = + failwith "boom" + SomeOutputType() + +let theAsyncAtHand () = + async { (someFunctionWithReturnType ()).End } + +try + theAsyncAtHand () |> Async.RunSynchronously + failwith "Expected exception was not raised." +with +| ex when ex.Message = "boom" -> () +""" + + [] + [] + [] + let ``TaskCE_NestedUnitPropertyAccess_PreservesReceiverSideEffects`` (optimize: bool) = + run optimize """ +type Inner() = + member x.End = () + +type Outer() = + member x.Inner = Inner() + +let makeOuter () = + failwith "boom" + Outer() + +let theTaskAtHand () = + task { (makeOuter ()).Inner.End } + +try + theTaskAtHand().Wait() + failwith "Expected exception was not raised; the optimizer dropped the side-effectful receiver." +with +| :? System.AggregateException as ex when ex.InnerException.Message = "boom" -> () +""" diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs index 070133a3d8d..e63654540a8 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Graph/FileContentMappingTests.fs @@ -122,6 +122,37 @@ module B = C | [ TopLevelNamespace "" [ PrefixedIdentifier "C" ] ] -> () | content -> Assert.Fail($"Unexpected content: {content}") +[] +let ``Long sequential chain captures all identifiers in order`` () = + // Regression test for https://github.com/dotnet/fsharp/issues/19988: a long statement + // sequence parses into a deeply nested SynExpr.Sequential chain, which is now flattened + // before traversal. Verifies the flattening preserves order and captures every entry. + let count = 10000 + + let statements = + [ for i in 0 .. count - 1 -> $" Ns{i}.f ()" ] |> String.concat "\n" + + let content = + getContent + false + $""" +module X.Y.Z + +let fn () = +{statements} +""" + + match content with + | [ TopLevelNamespace "X.Y" entries ] -> + let identifiers = + entries + |> List.map (function + | FileContentEntry.PrefixedIdentifier path -> String.concat "." path + | other -> failwith $"Unexpected entry: {other}") + + Assert.Equal([ for i in 0 .. count - 1 -> $"Ns{i}" ], identifiers) + | content -> Assert.Fail($"Unexpected content: {content}") + module InvalidSyntax = diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithExtensionMethod.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithExtensionMethod.fsx.realInternalSignatureOn.il.bsl index 18e650cc8b8..61dc0c7c4b2 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithExtensionMethod.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithExtensionMethod.fsx.realInternalSignatureOn.il.bsl @@ -111,17 +111,6 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class assembly/Foo get_f@9() cil managed { @@ -138,6 +127,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl index 84634a5460b..d4ffb003d44 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOff.il.bsl @@ -393,11 +393,11 @@ IL_0005: ret } - .method public specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_todo2() cil managed + .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 get_matchValue@25() cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> ''.$assembly$fsx::todo2@35 + IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 ''.$assembly$fsx::matchValue@25 IL_0005: ret } @@ -409,27 +409,27 @@ IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> 'get_computation@44-1'() cil managed + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_todo2() cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> ''.$assembly$fsx::'computation@44-1' + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> ''.$assembly$fsx::todo2@35 IL_0005: ret } - .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 get_matchValue@25() cil managed + .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 'get_matchValue@44-1'() cil managed { .maxstack 8 - IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 ''.$assembly$fsx::matchValue@25 + IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 ''.$assembly$fsx::'matchValue@44-1' IL_0005: ret } - .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 'get_matchValue@44-1'() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> 'get_computation@44-1'() cil managed { .maxstack 8 - IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 ''.$assembly$fsx::'matchValue@44-1' + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> ''.$assembly$fsx::'computation@44-1' IL_0005: ret } diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl index 5456e1c47f5..f98d3d3a6db 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithLastOpenedTypeExtensions.fsx.realInternalSignatureOn.il.bsl @@ -417,55 +417,55 @@ IL_0005: ret } - .method public specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_todo2() cil managed + .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 get_matchValue@25() cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::todo2@35 + IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 assembly::matchValue@25 IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_computation@25() cil managed { .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::computation@25 + IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_computation@25() cil managed + .method public specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> get_todo2() cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::computation@25 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::todo2@35 IL_0005: ret } - .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> 'get_computation@44-1'() cil managed + .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 'get_matchValue@44-1'() cil managed { .maxstack 8 - IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::'computation@44-1' + IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 assembly::'matchValue@44-1' IL_0005: ret } - .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 get_matchValue@25() cil managed + .method assembly specialname static class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> 'get_computation@44-1'() cil managed { .maxstack 8 - IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 assembly::matchValue@25 + IL_0000: ldsfld class [FSharp.Core]Microsoft.FSharp.Control.FSharpAsync`1> assembly::'computation@44-1' IL_0005: ret } - .method assembly specialname static valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 'get_matchValue@44-1'() cil managed + .method private specialname rtspecialname static void .cctor() cil managed { .maxstack 8 - IL_0000: ldsfld valuetype [FSharp.Core]Microsoft.FSharp.Core.FSharpResult`2 assembly::'matchValue@44-1' - IL_0005: ret + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret } .method assembly static void staticInitialization@() cil managed diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl index b29d9d083fb..cb0286dc082 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowWithTypeExtension.fsx.realInternalSignatureOn.il.bsl @@ -110,17 +110,6 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class assembly/Foo get_f@8() cil managed { @@ -137,6 +126,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowingAndStillOkWithChainedCalls.fsx.realInternalSignatureOn.il.bsl b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowingAndStillOkWithChainedCalls.fsx.realInternalSignatureOn.il.bsl index 09e19aa0a1b..833b0b9ec4c 100644 --- a/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowingAndStillOkWithChainedCalls.fsx.realInternalSignatureOn.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/TypeChecks/Shadowing/ShadowingAndStillOkWithChainedCalls.fsx.realInternalSignatureOn.il.bsl @@ -133,17 +133,6 @@ IL_0005: ret } - .method private specialname rtspecialname static void .cctor() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.0 - IL_0001: stsfld int32 ''.$assembly$fsx::init@ - IL_0006: ldsfld int32 ''.$assembly$fsx::init@ - IL_000b: pop - IL_000c: ret - } - .method assembly specialname static class assembly/Foo get_f@10() cil managed { @@ -160,6 +149,17 @@ IL_0005: ret } + .method private specialname rtspecialname static void .cctor() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 ''.$assembly$fsx::init@ + IL_0006: ldsfld int32 ''.$assembly$fsx::init@ + IL_000b: pop + IL_000c: ret + } + .method assembly static void staticInitialization@() cil managed { diff --git a/tests/FSharp.Compiler.Service.Tests/Symbols.fs b/tests/FSharp.Compiler.Service.Tests/Symbols.fs index d9a68b3f8c9..e7a1d5f683e 100644 --- a/tests/FSharp.Compiler.Service.Tests/Symbols.fs +++ b/tests/FSharp.Compiler.Service.Tests/Symbols.fs @@ -1530,6 +1530,78 @@ let test = System.DateTimeKind.Utc failwith "Expected metadata text, got None" | _ -> failwith "Expected FSharpEntity symbol" +module MetadataAsTextILField = + + let private getMetadataTextForEntity (entityName: string) (source: string) : string = + let _, checkResults = getParseAndCheckResults source + let symbolUse = checkResults |> findSymbolUseByName entityName + match symbolUse.Symbol with + | :? FSharpEntity as entity -> + match entity.TryGetMetadataText() with + | Some text -> text.ToString() + | None -> failwithf "Expected metadata text for %s, got None" entityName + | other -> failwithf "Expected FSharpEntity for %s, got %A" entityName other + + [] + [] + [] + [] + [] + [] + let ``IL literal static field renders with [] attribute and value`` + (typeName: string, fieldName: string, expectedValueText: string) = + let source = $"let _ = typeof<{typeName}>" + let shortName = typeName.Substring(typeName.LastIndexOf('.') + 1) + let metadataText = getMetadataTextForEntity shortName source + + Assert.Contains(fieldName, metadataText) + + let line = + metadataText.Split('\n') + |> Array.tryFind (fun l -> l.Contains("val " + fieldName + ":")) + |> Option.defaultWith (fun () -> failwithf "field declaration for %s not found in metadata text:\n%s" fieldName metadataText) + + Assert.Contains("[]", metadataText) + Assert.Contains("= " + expectedValueText, line) + + [] + let ``System.Char.MaxValue renders as a literal field`` () = + let metadataText = getMetadataTextForEntity "Char" "let _ = typeof" + + Assert.Contains("[]", metadataText) + let line = + metadataText.Split('\n') + |> Array.tryFind (fun l -> l.Contains("val MaxValue:")) + |> Option.defaultWith (fun () -> failwithf "MaxValue declaration not found:\n%s" metadataText) + Assert.Contains("=", line) + Assert.False(line.TrimEnd().EndsWith(": char"), + sprintf "MaxValue line is missing its literal value: %s" line) + + [] + let ``IL const string field renders with [] and the quoted string value`` () = + let metadataText = + getMetadataTextForEntity "RuntimeFeature" "let _ = typeof" + + Assert.Contains("[]", metadataText) + let line = + metadataText.Split('\n') + |> Array.tryFind (fun l -> l.Contains("val PortablePdb:")) + |> Option.defaultWith (fun () -> failwithf "PortablePdb declaration not found:\n%s" metadataText) + Assert.Contains("= \"PortablePdb\"", line) + Assert.DoesNotContain("value unavailable", line) + + [] + let ``System.String.Empty (initonly, non-literal) renders without [] and without value`` () = + let metadataText = getMetadataTextForEntity "String" "let _ = typeof" + + let line = + metadataText.Split('\n') + |> Array.tryFind (fun l -> l.Contains("val Empty:")) + |> Option.defaultWith (fun () -> failwithf "Empty not found:\n%s" metadataText) + + Assert.Contains("static val", line) + Assert.DoesNotContain("=", line) + module IsByRef = // https://github.com/dotnet/fsharp/issues/3532 [] diff --git a/tests/FSharp.Compiler.Service.Tests/SynExprTests.fs b/tests/FSharp.Compiler.Service.Tests/SynExprTests.fs index 69e85d816b5..8d8a0448902 100644 --- a/tests/FSharp.Compiler.Service.Tests/SynExprTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/SynExprTests.fs @@ -58,6 +58,17 @@ let exprs: obj array list = } " |] + // https://github.com/dotnet/fsharp/issues/17826 + // Sequential expressions used as record / anonymous record field values + // require their enclosing parentheses - otherwise the semicolon is parsed + // as a field separator. + [|[Needed]; "{| A = (1; 2) |}"|] + [|[Needed]; "{ A = (1; 2) }"|] + [|[Needed]; "{| A = ((); B = 3) |}"|] + [|[Needed]; "{| A = (printfn \"hi\"; 3) |}"|] + [|[Needed]; "{ existing with A = (1; 2) }"|] + [|[Needed; Needed]; "{| A = (1; 2); B = (3; 4) |}"|] + [|[Needed; Unneeded]; "{ Outer = ({ Inner = (1; 2) }) }"|] ] #if !NET6_0_OR_GREATER diff --git a/tests/ILVerify/ilverify.ps1 b/tests/ILVerify/ilverify.ps1 index afa812a860f..c870bbcf3d5 100644 --- a/tests/ILVerify/ilverify.ps1 +++ b/tests/ILVerify/ilverify.ps1 @@ -4,11 +4,11 @@ function Normalize-IlverifyOutputLine { param( [string]$line ) - # Remove F# closure suffixes: +clo@NNN-NNN, +clo@NNN, +NAME@NNN-NNN, +NAME@NNN + # Remove F# closure suffixes: +clo@NNN[-NNN], +NAME@NNN[-NNN] $line = $line -replace '(\+\w+)@\d+(-\d+)?', '$1' # Remove patterns like "Pipe #1 stage #1 at line 1782@1782" $line = $line -replace 'Pipe #\d+ stage #\d+ at line \d+@\d+', '' - # Remove function suffixes like NAME@NNN or NAME@NNN-NNN in method names + # Remove function suffixes like NAME@NNN[-NNN] in method names $line = $line -replace '(\w+)@\d+(-\d+)?', '$1' # Remove 'at line NNNN' $line = $line -replace 'at line \d+', '' diff --git a/tests/fsharp/Compiler/CodeGen/EmittedIL/DeterministicTests.fs b/tests/fsharp/Compiler/CodeGen/EmittedIL/DeterministicTests.fs index 0d678b442d1..d370e21be95 100644 --- a/tests/fsharp/Compiler/CodeGen/EmittedIL/DeterministicTests.fs +++ b/tests/fsharp/Compiler/CodeGen/EmittedIL/DeterministicTests.fs @@ -2,6 +2,7 @@ namespace FSharp.Compiler.UnitTests.CodeGen.EmittedIL +open System open System.IO open FSharp.Test open FSharp.Test.Compiler @@ -336,21 +337,15 @@ let inline myFunc x y = x - y""" // https://github.com/dotnet/fsharp/issues/19732 // Multi-file optimized compilation exercises DetupleArgs and TLR (tuple-arg - // functions + nested lambdas). These passes iterate Val sets whose order - // depends on Val.Stamp, which is racy under parallel optimization. - // The fix sorts by source position (valSourceOrderKey) before iterating. - // Note: this in-process test is a regression guard; the full race requires - // large-scale parallel compilation tested by eng/test-determinism.ps1 in Release. + // functions + nested lambdas); without source-order Val iteration their + // output races under parallel optimization. The full race needs eng/test-determinism.ps1 + // in Release — this is a regression guard. [] let ``Optimized multi-file assembly should be deterministic`` () = - let outputDir = DirectoryInfo(Path.Combine(Path.GetTempPath(), "fsharp-determinism-test")) - if outputDir.Exists then outputDir.Delete(true) + let outputDir = DirectoryInfo(Path.Combine(Path.GetTempPath(), $"fsharp-determinism-{Guid.NewGuid():N}")) outputDir.Create() - let makeFile i = - FsSourceWithFileName - $"File%d{i}.fs" - $""" + let fileBody i = $""" module File%d{i} let processTuple%d{i} (a: int, b: string) = @@ -366,26 +361,9 @@ let callSite%d{i} () = nested () """ - let additionalFiles = [ for i in 2..8 -> makeFile i ] - let getMvid () = - FSharp - """ -module File1 - -let processTuple1 (a: int, b: string) = - let inner x = x + a - (inner 1, b.Length) - -let callSite1 () = - let r1 = processTuple1 (42, "hello") - let r2 = processTuple1 (99, "world") - let nested () = - let deep () = fst r1 + fst r2 - deep () - nested () -""" - |> withAdditionalSourceFiles additionalFiles + FSharp(fileBody 1) + |> withAdditionalSourceFiles [ for i in 2..8 -> FsSourceWithFileName $"File%d{i}.fs" (fileBody i) ] |> asLibrary |> withOptimize |> withName "DetTest" @@ -393,12 +371,13 @@ let callSite1 () = |> withOptions [ "--deterministic" ] |> compileGuid - let mvids = [| for _ in 1..10 -> getMvid () |] - - for i in 1 .. mvids.Length - 1 do - Assert.Equal(mvids.[0], mvids.[i]) + try + let mvids = [| for _ in 1..10 -> getMvid () |] - outputDir.Delete(true) + for i in 1 .. mvids.Length - 1 do + Assert.Equal(mvids.[0], mvids.[i]) + finally + outputDir.Delete(true) [] let ``Reference assemblies MVID must change when literal constant value changes`` () = @@ -417,3 +396,167 @@ let X = 43 let mvid1, mvid2 = calculateRefAssMvids codeWithLiteral42 codeWithLiteral43 // Different literal values should produce different MVIDs Assert.NotEqual(mvid1, mvid2) + + // Guards stableValKey total ordering: same-arity overloads (f(int) vs f(string)) + // must serialize in deterministic order in p_ModuleInfo optimization data. + [] + let ``Overloaded members produce deterministic MVID`` () = + let outputDir = DirectoryInfo(Path.Combine(Path.GetTempPath(), $"fsharp-overload-{Guid.NewGuid():N}")) + outputDir.Create() + + let libFile = """ +module OverloadLib + +type Processor() = + member _.Handle(x: int) = x * 2 + member _.Handle(x: string) = x.Length + member _.Handle(x: float) = int x + member _.Handle(x: int, y: int) = x + y +""" + + let consumerFile = """ +module Consumer + +let run () = + let p = OverloadLib.Processor() + p.Handle(42) + p.Handle("hello") + p.Handle(3.14) + p.Handle(1, 2) +""" + + let getMvid () = + FSharp(libFile) + |> withAdditionalSourceFiles [ FsSourceWithFileName "Consumer.fs" consumerFile ] + |> asLibrary + |> withOptimize + |> withName "OverloadTest" + |> withOutputDirectory (Some outputDir) + |> withOptions [ "--deterministic"; "--nowarn:75" ] + |> compileGuid + + try + Assert.Equal(getMvid (), getMvid ()) + finally + outputDir.Delete(true) + + // https://github.com/dotnet/fsharp/issues/19928 + // The core SEQ=PAR invariant: sequential and parallel codegen must produce identical output. + // Exercises cross-file inlined closures, byte arrays, and the full deferred drain pipeline. + [] + let ``Sequential and parallel codegen produce identical MVID`` () = + let outputDir = DirectoryInfo(Path.Combine(Path.GetTempPath(), $"fsharp-seqpar-{Guid.NewGuid():N}")) + outputDir.Create() + + let libFile = """ +module Lib + +let inline withClosure f x = (fun y -> f y + x) 1 + +let data1 = [| 0uy .. 200uy |] +let data2 = [| 1us; 2us; 3us; 4us; 5us; 6us; 7us; 8us |] +""" + + let consumerFile i = $""" +module Consumer%d{i} + +let result%d{i} () = + let v = Lib.withClosure (fun y -> y * %d{i}) %d{i + 10} + v + int Lib.data1.[%d{i}] + int Lib.data2.[%d{i % 8}] +""" + + let getMvid (parallelFlag: string) = + FSharp(libFile) + |> withAdditionalSourceFiles [ for i in 1..30 -> FsSourceWithFileName $"Consumer%d{i}.fs" (consumerFile i) ] + |> asLibrary + |> withOptimize + |> withName "SeqParTest" + |> withOutputDirectory (Some outputDir) + |> withOptions [ "--deterministic"; "--nowarn:75"; parallelFlag ] + |> compileGuid + + try + let seqMvid = getMvid "--parallelcompilation-" + let parMvid = getMvid "--parallelcompilation+" + Assert.Equal(seqMvid, parMvid) + finally + outputDir.Delete(true) + + // bytesKey correctness: two distinct inline byte arrays in one function body get the same + // range after remarkExpr inlining. Without bytesKey they would alias → wrong runtime values. + [] + let ``Inline byte arrays with same range produce distinct correct values`` () = + let libFile = """ +module Lib +let inline twoArrays () = ([| 10uy; 20uy; 30uy; 40uy; 50uy; 60uy |], [| 99uy; 88uy; 77uy; 66uy; 55uy; 44uy |]) +""" + + let mainFile = """ +module Main +[] +let main _ = + let (a, b) = Lib.twoArrays () + if a.[0] = 10uy && b.[0] = 99uy then + printfn "OK" + 0 + else + printfn "FAIL: %d %d" a.[0] b.[0] + 1 +""" + + FSharp(libFile) + |> withAdditionalSourceFiles [ FsSourceWithFileName "Main.fs" mainFile ] + |> asExe + |> withOptimize + |> withOptions [ "--deterministic"; "--nowarn:75"; "--parallelcompilation+" ] + |> compileAndRun + |> shouldSucceed + |> withStdOutContains "OK" + |> ignore + + // Verify that compiled output actually runs correctly — not just that IL is identical. + // Guards against the FSharpPlus-class runtime hang caused by dropped .cctor initialization. + [] + [] + [] + let ``Deterministic multi-file compile produces correct runtime behavior`` (parallelFlag: string) = + let mainFile = """ +module Main + +[] +let main _ = + let r1 = ModuleA.valueA + let r2 = ModuleB.valueB + if r1 = 42 && r2 = 99 then + printfn "OK" + 0 + else + printfn "FAIL: %d %d" r1 r2 + 1 +""" + + let moduleA = """ +module ModuleA + +let mutable sideEffect = 0 +do sideEffect <- 42 +let valueA = sideEffect +""" + + let moduleB = """ +module ModuleB + +let mutable sideEffect = 0 +do sideEffect <- 99 +let valueB = sideEffect +""" + + FSharp(moduleA) + |> withAdditionalSourceFiles [ + FsSourceWithFileName "ModuleB.fs" moduleB + FsSourceWithFileName "Main.fs" mainFile + ] + |> asExe + |> withOptimize + |> withOptions [ "--deterministic"; "--nowarn:75"; parallelFlag ] + |> compileAndRun + |> shouldSucceed + |> withStdOutContains "OK" + |> ignore