From dfbf7740f248c5052c0d2459a9ffd1e3569d5f4e Mon Sep 17 00:00:00 2001 From: Petr Date: Mon, 22 Jul 2024 20:15:50 +0200 Subject: [PATCH 1/7] Update docs for an operator --- src/FSharp.Core/prim-types.fsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Core/prim-types.fsi b/src/FSharp.Core/prim-types.fsi index ae631cf2114..8b35a81e886 100644 --- a/src/FSharp.Core/prim-types.fsi +++ b/src/FSharp.Core/prim-types.fsi @@ -2788,7 +2788,7 @@ namespace Microsoft.FSharp.Core /// /// /// 2 + 2 // Evaluates to 4 - /// "Hello " + "Word" // Evaluates to "Hello World" + /// "Hello " + "World" // Evaluates to "Hello World" /// /// /// From f684341f88e8e571d30a84e5410bab4b2f8df1cb Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Tue, 23 Jul 2024 12:48:43 +0200 Subject: [PATCH 2/7] Remove xliff-tasks from Version.Details.xml --- eng/Version.Details.xml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 1c95f668e36..618a642e481 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -52,17 +52,6 @@ 4a7d983f833d6b86365ea1b2b4d6ee72fbdbf944 - - https://github.com/dotnet/xliff-tasks - 73f0850939d96131c28cf6ea6ee5aacb4da0083a - - - - https://github.com/dotnet/xliff-tasks - 73f0850939d96131c28cf6ea6ee5aacb4da0083a - - https://dev.azure.com/dnceng/internal/_git/dotnet-optimization 15f6d606bfc7cbb65587dd7bc1ec6e9ef283f7e3 From 15e6c3423fbde007d5ea1a0b581111fbcdb9d44f Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Fri, 26 Jul 2024 21:35:28 +0200 Subject: [PATCH 3/7] Make loading of FSharp.Build optional in UseLocalCompiler.Directory.Build.props (#17417) --- UseLocalCompiler.Directory.Build.props | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/UseLocalCompiler.Directory.Build.props b/UseLocalCompiler.Directory.Build.props index 013483bd65c..74ac88743c0 100644 --- a/UseLocalCompiler.Directory.Build.props +++ b/UseLocalCompiler.Directory.Build.props @@ -1,5 +1,7 @@ + False + Release $(MSBuildThisFileDirectory) @@ -12,7 +14,9 @@ False True + + $(LocalFSharpCompilerPath)/artifacts/bin/fsc/$(LocalFSharpCompilerConfiguration)/net9.0 $(LocalFSharpBuildBinPath)/FSharp.Build.dll $(LocalFSharpBuildBinPath)/Microsoft.FSharp.Targets @@ -21,8 +25,8 @@ $(LocalFSharpBuildBinPath)/Microsoft.FSharp.Overrides.NetSdk.targets - - + + From d6507d6531f9998b16242514c2e11f301742a66c Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Sat, 27 Jul 2024 13:47:11 -0400 Subject: [PATCH 4/7] Optimize simple mappings with binds and/or sequentials before single yield (#17419) --- .../.FSharp.Compiler.Service/9.0.100.md | 1 + .../Optimize/LowerComputedCollections.fs | 63 +- src/Compiler/TypedTree/TypedTreeOps.fs | 11 +- .../ComputedCollections/ForNInRangeArrays.fs | 7 + .../ForNInRangeArrays.fs.il.bsl | 372 ++++++++++ .../ComputedCollections/ForNInRangeLists.fs | 7 + .../ForNInRangeLists.fs.il.bsl | 345 +++++++++ .../ForXInArray_ToArray.fs | 13 +- .../ForXInArray_ToArray.fs.il.bsl | 536 ++++++++++++++ .../ComputedCollections/ForXInArray_ToList.fs | 13 +- .../ForXInArray_ToList.fs.il.bsl | 667 ++++++++++++++++++ .../ComputedCollections/ForXInList_ToArray.fs | 13 +- .../ForXInList_ToArray.fs.il.bsl | 661 +++++++++++++++++ .../ComputedCollections/ForXInList_ToList.fs | 13 +- .../ForXInList_ToList.fs.il.bsl | 515 ++++++++++++++ .../ComputedCollections/ForXInSeq_ToArray.fs | 13 +- .../ForXInSeq_ToArray.fs.il.bsl | 661 +++++++++++++++++ .../ComputedCollections/ForXInSeq_ToList.fs | 13 +- .../ForXInSeq_ToList.fs.il.bsl | 667 ++++++++++++++++++ 19 files changed, 4566 insertions(+), 25 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index f9e23daca3d..9a65849c833 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -2,6 +2,7 @@ * Compiler hangs when compiling inline recursive invocation ([Issue #17376](https://github.com/dotnet/fsharp/issues/17376), [PR #17394](https://github.com/dotnet/fsharp/pull/17394)) * Fix reporting IsFromComputationExpression only for CE builder type constructors and let bindings. ([PR #17375](https://github.com/dotnet/fsharp/pull/17375)) +* Optimize simple mappings in comprehensions when the body of the mapping has `let`-bindings and/or sequential expressions before a single yield. ([PR #17419](https://github.com/dotnet/fsharp/pull/17419)) ### Added diff --git a/src/Compiler/Optimize/LowerComputedCollections.fs b/src/Compiler/Optimize/LowerComputedCollections.fs index fbef32dcb4b..98b01086cc6 100644 --- a/src/Compiler/Optimize/LowerComputedCollections.fs +++ b/src/Compiler/Optimize/LowerComputedCollections.fs @@ -524,22 +524,46 @@ module Array = ) ) -/// f (); …; Seq.singleton x +/// Matches Seq.singleton and returns the body expression. +[] +let (|SeqSingleton|_|) g expr : Expr voption = + match expr with + | ValApp g g.seq_singleton_vref (_, [body], _) -> ValueSome body + | _ -> ValueNone + +/// Matches the compiled representation of the mapping in +/// +/// for … in … do f (); …; yield … +/// for … in … do let … = … in yield … +/// for … in … do f (); …; … +/// for … in … do let … = … in … /// -/// E.g., in [for x in … do f (); …; yield x] +/// i.e., +/// +/// f (); …; Seq.singleton … +/// let … = … in Seq.singleton … [] -let (|SimpleSequential|_|) g expr : Expr voption = +let (|SingleYield|_|) g expr : Expr voption = let rec loop expr cont = match expr with - | Expr.Sequential (expr1, DebugPoints (ValApp g g.seq_singleton_vref (_, [body], _), debug), kind, m) -> - ValueSome (cont (expr1, debug body, kind, m)) + | Expr.Let (binding, DebugPoints (SeqSingleton g body, debug), m, frees) -> + ValueSome (cont (Expr.Let (binding, debug body, m, frees))) + + | Expr.Let (binding, DebugPoints (body, debug), m, frees) -> + loop body (cont << fun body -> Expr.Let (binding, debug body, m, frees)) + + | Expr.Sequential (expr1, DebugPoints (SeqSingleton g body, debug), kind, m) -> + ValueSome (cont (Expr.Sequential (expr1, debug body, kind, m))) | Expr.Sequential (expr1, DebugPoints (body, debug), kind, m) -> - loop body (cont >> fun body -> Expr.Sequential (expr1, debug body, kind, m)) + loop body (cont << fun body -> Expr.Sequential (expr1, debug body, kind, m)) + + | SeqSingleton g body -> + ValueSome (cont body) | _ -> ValueNone - loop expr Expr.Sequential + loop expr id /// Extracts any let-bindings or sequential /// expressions that directly precede the specified mapping application, e.g., @@ -573,11 +597,9 @@ let gatherPrelude ((|App|_|) : _ -> _ voption) expr = /// The representation used for /// -/// for … in … -> … -/// -/// and -/// -/// for … in … do yield … +/// for … in … -> … +/// for … in … do yield … +/// for … in … do … [] let (|SeqMap|_|) g = gatherPrelude (function @@ -592,30 +614,41 @@ let (|SeqMap|_|) g = /// The representation used for /// -/// for … in … do f (); …; yield … +/// for … in … do f (); …; yield … +/// for … in … do let … = … in yield … +/// for … in … do f (); …; … +/// for … in … do let … = … in … [] let (|SeqCollectSingle|_|) g = gatherPrelude (function - | ValApp g g.seq_collect_vref ([ty1; _; ty2], [Expr.Lambda (valParams = [loopVal]; bodyExpr = SimpleSequential g body; range = mIn) as mapping; input], mFor) -> + | ValApp g g.seq_collect_vref ([ty1; _; ty2], [Expr.Lambda (valParams = [loopVal]; bodyExpr = DebugPoints (SingleYield g body, debug); range = mIn) as mapping; input], mFor) -> let spIn = match mIn.NotedSourceConstruct with NotedSourceConstruct.InOrTo -> DebugPointAtInOrTo.Yes mIn | _ -> DebugPointAtInOrTo.No let spFor = DebugPointAtBinding.Yes mFor let spInWhile = match spIn with DebugPointAtInOrTo.Yes m -> DebugPointAtWhile.Yes m | DebugPointAtInOrTo.No -> DebugPointAtWhile.No let ranges = body.Range, spFor, spIn, mFor, mIn, spInWhile - ValueSome (ty1, ty2, input, mapping, loopVal, body, ranges) + ValueSome (ty1, ty2, input, mapping, loopVal, debug body, ranges) | _ -> ValueNone) /// for … in … -> … /// for … in … do yield … +/// for … in … do … /// for … in … do f (); …; yield … +/// for … in … do let … = … in yield … +/// for … in … do f (); …; … +/// for … in … do let … = … in … [] let (|SimpleMapping|_|) g expr = match expr with // for … in … -> … // for … in … do yield … + // for … in … do … | ValApp g g.seq_delay_vref (_, [Expr.Lambda (bodyExpr = DebugPoints (SeqMap g (cont, (ty1, ty2, input, mapping, loopVal, body, ranges)), debug))], _) // for … in … do f (); …; yield … + // for … in … do let … = … in yield … + // for … in … do f (); …; … + // for … in … do let … = … in … | ValApp g g.seq_delay_vref (_, [Expr.Lambda (bodyExpr = DebugPoints (SeqCollectSingle g (cont, (ty1, ty2, input, mapping, loopVal, body, ranges)), debug))], _) -> ValueSome (debug >> cont, (ty1, ty2, input, mapping, loopVal, body, ranges)) diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 847e695f55a..685f9a7377c 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -1271,11 +1271,14 @@ let rec stripDebugPoints expr = | Expr.DebugPoint (_, innerExpr) -> stripDebugPoints innerExpr | expr -> expr -// Strip debug points and remember how to recrete them +// Strip debug points and remember how to recreate them let (|DebugPoints|) expr = - match stripExpr expr with - | Expr.DebugPoint (dp, innerExpr) -> innerExpr, (fun e -> Expr.DebugPoint(dp, e)) - | expr -> expr, id + let rec loop expr debug = + match stripExpr expr with + | Expr.DebugPoint (dp, innerExpr) -> loop innerExpr (debug << fun e -> Expr.DebugPoint (dp, e)) + | expr -> expr, debug + + loop expr id let mkCase (a, b) = TCase(a, b) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs index e2466ab7f5f..b7fe4dddd21 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs @@ -2,6 +2,13 @@ let f00 f g = [|for n in 1..10 do f (); g (); yield n|] let f000 f = [|for n in 1..10 do f (); yield n; yield n + 1|] let f0000 () = [|for n in 1..10 do yield n|] +let f00000 () = [|for n in 1..10 do n|] +let f000000 () = [|for n in 1..10 do let n = n in n|] +let f0000000 () = [|for n in 1..10 do let n = n in yield n|] +let f00000000 () = [|for n in 1..10 do let n = n in let n = n in yield n|] +let f000000000 x y = [|for n in 1..10 do let foo = n + x in let bar = n + y in yield n + foo + bar|] +let f0000000000 f g = [|for n in 1..10 do f (); g (); n|] +let f00000000000 (f : unit -> int) (g : unit -> int) = [|for n in 1..10 do f (); g (); n|] let f1 () = [|for n in 1..10 -> n|] let f2 () = [|for n in 10..1 -> n|] let f3 () = [|for n in 1..1..10 -> n|] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs.il.bsl index 2a721ca3560..681768099ef 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeArrays.fs.il.bsl @@ -260,6 +260,378 @@ IL_0028: ret } + .method public static int32[] f00000() cil managed + { + + .maxstack 5 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0021 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: ldloc.3 + IL_0017: stelem.i4 + IL_0018: ldloc.2 + IL_0019: ldc.i4.1 + IL_001a: add + IL_001b: stloc.2 + IL_001c: ldloc.1 + IL_001d: ldc.i4.1 + IL_001e: conv.i8 + IL_001f: add + IL_0020: stloc.1 + IL_0021: ldloc.1 + IL_0022: ldc.i4.s 10 + IL_0024: conv.i8 + IL_0025: blt.un.s IL_0011 + + IL_0027: ldloc.0 + IL_0028: ret + } + + .method public static int32[] f000000() cil managed + { + + .maxstack 5 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0022 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: nop + IL_0017: ldloc.3 + IL_0018: stelem.i4 + IL_0019: ldloc.2 + IL_001a: ldc.i4.1 + IL_001b: add + IL_001c: stloc.2 + IL_001d: ldloc.1 + IL_001e: ldc.i4.1 + IL_001f: conv.i8 + IL_0020: add + IL_0021: stloc.1 + IL_0022: ldloc.1 + IL_0023: ldc.i4.s 10 + IL_0025: conv.i8 + IL_0026: blt.un.s IL_0011 + + IL_0028: ldloc.0 + IL_0029: ret + } + + .method public static int32[] f0000000() cil managed + { + + .maxstack 5 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0022 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: nop + IL_0017: ldloc.3 + IL_0018: stelem.i4 + IL_0019: ldloc.2 + IL_001a: ldc.i4.1 + IL_001b: add + IL_001c: stloc.2 + IL_001d: ldloc.1 + IL_001e: ldc.i4.1 + IL_001f: conv.i8 + IL_0020: add + IL_0021: stloc.1 + IL_0022: ldloc.1 + IL_0023: ldc.i4.s 10 + IL_0025: conv.i8 + IL_0026: blt.un.s IL_0011 + + IL_0028: ldloc.0 + IL_0029: ret + } + + .method public static int32[] f00000000() cil managed + { + + .maxstack 5 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0023 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: nop + IL_0017: nop + IL_0018: ldloc.3 + IL_0019: stelem.i4 + IL_001a: ldloc.2 + IL_001b: ldc.i4.1 + IL_001c: add + IL_001d: stloc.2 + IL_001e: ldloc.1 + IL_001f: ldc.i4.1 + IL_0020: conv.i8 + IL_0021: add + IL_0022: stloc.1 + IL_0023: ldloc.1 + IL_0024: ldc.i4.s 10 + IL_0026: conv.i8 + IL_0027: blt.un.s IL_0011 + + IL_0029: ldloc.0 + IL_002a: ret + } + + .method public static int32[] f000000000(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0031 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: ldloc.3 + IL_0017: ldarg.0 + IL_0018: add + IL_0019: stloc.s V_4 + IL_001b: ldloc.3 + IL_001c: ldarg.1 + IL_001d: add + IL_001e: stloc.s V_5 + IL_0020: ldloc.3 + IL_0021: ldloc.s V_4 + IL_0023: add + IL_0024: ldloc.s V_5 + IL_0026: add + IL_0027: stelem.i4 + IL_0028: ldloc.2 + IL_0029: ldc.i4.1 + IL_002a: add + IL_002b: stloc.2 + IL_002c: ldloc.1 + IL_002d: ldc.i4.1 + IL_002e: conv.i8 + IL_002f: add + IL_0030: stloc.1 + IL_0031: ldloc.1 + IL_0032: ldc.i4.s 10 + IL_0034: conv.i8 + IL_0035: blt.un.s IL_0011 + + IL_0037: ldloc.0 + IL_0038: ret + } + + .method public static int32[] f0000000000(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 g) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: conv.i8 + IL_0003: conv.ovf.i.un + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: conv.i8 + IL_000c: stloc.1 + IL_000d: ldc.i4.1 + IL_000e: stloc.2 + IL_000f: br.s IL_0031 + + IL_0011: ldloc.0 + IL_0012: ldloc.1 + IL_0013: conv.i + IL_0014: ldloc.2 + IL_0015: stloc.3 + IL_0016: ldarg.0 + IL_0017: ldnull + IL_0018: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001d: pop + IL_001e: ldarg.1 + IL_001f: ldnull + IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0025: pop + IL_0026: ldloc.3 + IL_0027: stelem.i4 + IL_0028: ldloc.2 + IL_0029: ldc.i4.1 + IL_002a: add + IL_002b: stloc.2 + IL_002c: ldloc.1 + IL_002d: ldc.i4.1 + IL_002e: conv.i8 + IL_002f: add + IL_0030: stloc.1 + IL_0031: ldloc.1 + IL_0032: ldc.i4.s 10 + IL_0034: conv.i8 + IL_0035: blt.un.s IL_0011 + + IL_0037: ldloc.0 + IL_0038: ret + } + + .method public static int32[] f00000000000(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 g) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: ldc.i4.1 + IL_0003: ldc.i4.s 10 + IL_0005: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeInt32(int32, + int32, + int32) + IL_000a: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000f: stloc.1 + .try + { + IL_0010: br.s IL_0040 + + IL_0012: ldloc.1 + IL_0013: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0018: stloc.3 + IL_0019: ldloca.s V_0 + IL_001b: ldarg.0 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0027: nop + IL_0028: ldloca.s V_0 + IL_002a: ldarg.1 + IL_002b: ldnull + IL_002c: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0031: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0036: nop + IL_0037: ldloca.s V_0 + IL_0039: ldloc.3 + IL_003a: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_003f: nop + IL_0040: ldloc.1 + IL_0041: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0046: brtrue.s IL_0012 + + IL_0048: ldnull + IL_0049: stloc.2 + IL_004a: leave.s IL_0061 + + } + finally + { + IL_004c: ldloc.1 + IL_004d: isinst [runtime]System.IDisposable + IL_0052: stloc.s V_4 + IL_0054: ldloc.s V_4 + IL_0056: brfalse.s IL_0060 + + IL_0058: ldloc.s V_4 + IL_005a: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_005f: endfinally + IL_0060: endfinally + } + IL_0061: ldloc.2 + IL_0062: pop + IL_0063: ldloca.s V_0 + IL_0065: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_006a: ret + } + .method public static int32[] f1() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs index 28a0890e1e4..277b51060c8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs @@ -2,6 +2,13 @@ let f00 f g = [|for n in 1..10 do f (); g (); yield n|] let f000 f = [for n in 1..10 do f (); yield n; yield n + 1] let f0000 () = [for n in 1..10 do yield n] +let f00000 () = [for n in 1..10 do n] +let f000000 () = [for n in 1..10 do let n = n in n] +let f0000000 () = [for n in 1..10 do let n = n in yield n] +let f00000000 () = [for n in 1..10 do let n = n in let n = n in yield n] +let f000000000 x y = [for n in 1..10 do let foo = n + x in let bar = n + y in yield n + foo + bar] +let f0000000000 f g = [for n in 1..10 do f (); g (); n] +let f00000000000 (f : unit -> int) (g : unit -> int) = [for n in 1..10 do f (); g (); n] let f1 () = [for n in 1..10 -> n] let f2 () = [for n in 10..1 -> n] let f3 () = [for n in 1..1..10 -> n] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs.il.bsl index 3c43939bb29..e4145ab1e12 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForNInRangeLists.fs.il.bsl @@ -250,6 +250,351 @@ IL_0028: ret } + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f00000() cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_001b + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: ldloc.3 + IL_000c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0011: nop + IL_0012: ldloc.2 + IL_0013: ldc.i4.1 + IL_0014: add + IL_0015: stloc.2 + IL_0016: ldloc.1 + IL_0017: ldc.i4.1 + IL_0018: conv.i8 + IL_0019: add + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldc.i4.s 10 + IL_001e: conv.i8 + IL_001f: blt.un.s IL_0007 + + IL_0021: ldloca.s V_0 + IL_0023: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0028: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f000000() cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_001c + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: nop + IL_000c: ldloc.3 + IL_000d: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0012: nop + IL_0013: ldloc.2 + IL_0014: ldc.i4.1 + IL_0015: add + IL_0016: stloc.2 + IL_0017: ldloc.1 + IL_0018: ldc.i4.1 + IL_0019: conv.i8 + IL_001a: add + IL_001b: stloc.1 + IL_001c: ldloc.1 + IL_001d: ldc.i4.s 10 + IL_001f: conv.i8 + IL_0020: blt.un.s IL_0007 + + IL_0022: ldloca.s V_0 + IL_0024: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0029: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0000000() cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_001c + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: nop + IL_000c: ldloc.3 + IL_000d: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0012: nop + IL_0013: ldloc.2 + IL_0014: ldc.i4.1 + IL_0015: add + IL_0016: stloc.2 + IL_0017: ldloc.1 + IL_0018: ldc.i4.1 + IL_0019: conv.i8 + IL_001a: add + IL_001b: stloc.1 + IL_001c: ldloc.1 + IL_001d: ldc.i4.s 10 + IL_001f: conv.i8 + IL_0020: blt.un.s IL_0007 + + IL_0022: ldloca.s V_0 + IL_0024: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0029: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f00000000() cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_001d + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: nop + IL_000c: nop + IL_000d: ldloc.3 + IL_000e: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0013: nop + IL_0014: ldloc.2 + IL_0015: ldc.i4.1 + IL_0016: add + IL_0017: stloc.2 + IL_0018: ldloc.1 + IL_0019: ldc.i4.1 + IL_001a: conv.i8 + IL_001b: add + IL_001c: stloc.1 + IL_001d: ldloc.1 + IL_001e: ldc.i4.s 10 + IL_0020: conv.i8 + IL_0021: blt.un.s IL_0007 + + IL_0023: ldloca.s V_0 + IL_0025: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_002a: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000000(int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_002b + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: ldloc.3 + IL_000c: ldarg.0 + IL_000d: add + IL_000e: stloc.s V_4 + IL_0010: ldloc.3 + IL_0011: ldarg.1 + IL_0012: add + IL_0013: stloc.s V_5 + IL_0015: ldloc.3 + IL_0016: ldloc.s V_4 + IL_0018: add + IL_0019: ldloc.s V_5 + IL_001b: add + IL_001c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0021: nop + IL_0022: ldloc.2 + IL_0023: ldc.i4.1 + IL_0024: add + IL_0025: stloc.2 + IL_0026: ldloc.1 + IL_0027: ldc.i4.1 + IL_0028: conv.i8 + IL_0029: add + IL_002a: stloc.1 + IL_002b: ldloc.1 + IL_002c: ldc.i4.s 10 + IL_002e: conv.i8 + IL_002f: blt.un.s IL_0007 + + IL_0031: ldloca.s V_0 + IL_0033: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0038: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000000(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 g) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + uint64 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.0 + IL_0001: conv.i8 + IL_0002: stloc.1 + IL_0003: ldc.i4.1 + IL_0004: stloc.2 + IL_0005: br.s IL_002b + + IL_0007: ldloca.s V_0 + IL_0009: ldloc.2 + IL_000a: stloc.3 + IL_000b: ldarg.0 + IL_000c: ldnull + IL_000d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0012: pop + IL_0013: ldarg.1 + IL_0014: ldnull + IL_0015: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001a: pop + IL_001b: ldloc.3 + IL_001c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0021: nop + IL_0022: ldloc.2 + IL_0023: ldc.i4.1 + IL_0024: add + IL_0025: stloc.2 + IL_0026: ldloc.1 + IL_0027: ldc.i4.1 + IL_0028: conv.i8 + IL_0029: add + IL_002a: stloc.1 + IL_002b: ldloc.1 + IL_002c: ldc.i4.s 10 + IL_002e: conv.i8 + IL_002f: blt.un.s IL_0007 + + IL_0031: ldloca.s V_0 + IL_0033: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0038: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000000000(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 g) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 02 00 00 00 01 00 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldc.i4.1 + IL_0002: ldc.i4.1 + IL_0003: ldc.i4.s 10 + IL_0005: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeInt32(int32, + int32, + int32) + IL_000a: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_000f: stloc.1 + .try + { + IL_0010: br.s IL_0040 + + IL_0012: ldloc.1 + IL_0013: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0018: stloc.3 + IL_0019: ldloca.s V_0 + IL_001b: ldarg.0 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0027: nop + IL_0028: ldloca.s V_0 + IL_002a: ldarg.1 + IL_002b: ldnull + IL_002c: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0031: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0036: nop + IL_0037: ldloca.s V_0 + IL_0039: ldloc.3 + IL_003a: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_003f: nop + IL_0040: ldloc.1 + IL_0041: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0046: brtrue.s IL_0012 + + IL_0048: ldnull + IL_0049: stloc.2 + IL_004a: leave.s IL_0061 + + } + finally + { + IL_004c: ldloc.1 + IL_004d: isinst [runtime]System.IDisposable + IL_0052: stloc.s V_4 + IL_0054: ldloc.s V_4 + IL_0056: brfalse.s IL_0060 + + IL_0058: ldloc.s V_4 + IL_005a: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_005f: endfinally + IL_0060: endfinally + } + IL_0061: ldloc.2 + IL_0062: pop + IL_0063: ldloca.s V_0 + IL_0065: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_006a: ret + } + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f1() cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs index c552cb7dee1..6b074654e45 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs @@ -1,4 +1,15 @@ -let f1 (array: int array) = [|for x in array -> x|] +let f0 (array: int array) = [|for x in array do x|] +let f00 (array: int array) = [|for x in array do yield x|] +let f000 (array: int array) = [|for x in array do let x = x in yield x|] +let f0000 (array: int array) = [|for x in array do let x = x in x|] +let f00000 (array: int array) x y = [|for z in array do let foo = z + x in let bar = z + y in yield z + foo + bar|] +let f000000 (array: int array) x y = [|for z in array do let foo = z + x in let bar = z + y in z + foo + bar|] +let f0000000 (array: int array) f x y = [|for z in array do f (); let foo = z + x in let bar = z + y in z + foo + bar|] +let f00000000 (array: int array) f x y = [|for z in array do let foo = z + x in f (); let bar = z + y in z + foo + bar|] +let f000000000 (array: int array) f x y = [|for z in array do let foo = z + x in let bar = z + y in f (); z + foo + bar|] +let f0000000000 (array: int array) (f : unit -> int) x y = [|for z in array do let foo = z + x in let bar = z + y in f (); z + foo + bar|] + +let f1 (array: int array) = [|for x in array -> x|] let f2 f (array: int array) = [|for x in array -> f x|] let f3 f (array: int array) = [|for x in array -> f (); x|] let f4 f g (array: int array) = [|for x in array -> f (); g(); x|] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs.il.bsl index 8da4e158185..4839243ebdb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToArray.fs.il.bsl @@ -43,6 +43,542 @@ 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 static int32[] f0(int32[] 'array') cil managed + { + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_001a + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: stelem.i4 + IL_0016: ldloc.1 + IL_0017: ldc.i4.1 + IL_0018: add + IL_0019: stloc.1 + IL_001a: ldloc.1 + IL_001b: ldloc.0 + IL_001c: ldlen + IL_001d: conv.i4 + IL_001e: blt.s IL_000e + + IL_0020: ldloc.0 + IL_0021: ret + } + + .method public static int32[] f00(int32[] 'array') cil managed + { + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_001a + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: stelem.i4 + IL_0016: ldloc.1 + IL_0017: ldc.i4.1 + IL_0018: add + IL_0019: stloc.1 + IL_001a: ldloc.1 + IL_001b: ldloc.0 + IL_001c: ldlen + IL_001d: conv.i4 + IL_001e: blt.s IL_000e + + IL_0020: ldloc.0 + IL_0021: ret + } + + .method public static int32[] f000(int32[] 'array') cil managed + { + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_001b + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: nop + IL_0015: ldloc.2 + IL_0016: stelem.i4 + IL_0017: ldloc.1 + IL_0018: ldc.i4.1 + IL_0019: add + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldloc.0 + IL_001d: ldlen + IL_001e: conv.i4 + IL_001f: blt.s IL_000e + + IL_0021: ldloc.0 + IL_0022: ret + } + + .method public static int32[] f0000(int32[] 'array') cil managed + { + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_001b + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: nop + IL_0015: ldloc.2 + IL_0016: stelem.i4 + IL_0017: ldloc.1 + IL_0018: ldc.i4.1 + IL_0019: add + IL_001a: stloc.1 + IL_001b: ldloc.1 + IL_001c: ldloc.0 + IL_001d: ldlen + IL_001e: conv.i4 + IL_001f: blt.s IL_000e + + IL_0021: ldloc.0 + IL_0022: ret + } + + .method public static int32[] f00000(int32[] 'array', + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2, + int32 V_3, + int32 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_0028 + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: ldarg.1 + IL_0016: add + IL_0017: stloc.3 + IL_0018: ldloc.2 + IL_0019: ldarg.2 + IL_001a: add + IL_001b: stloc.s V_4 + IL_001d: ldloc.2 + IL_001e: ldloc.3 + IL_001f: add + IL_0020: ldloc.s V_4 + IL_0022: add + IL_0023: stelem.i4 + IL_0024: ldloc.1 + IL_0025: ldc.i4.1 + IL_0026: add + IL_0027: stloc.1 + IL_0028: ldloc.1 + IL_0029: ldloc.0 + IL_002a: ldlen + IL_002b: conv.i4 + IL_002c: blt.s IL_000e + + IL_002e: ldloc.0 + IL_002f: ret + } + + .method public static int32[] f000000(int32[] 'array', + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2, + int32 V_3, + int32 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_0028 + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: ldarg.1 + IL_0016: add + IL_0017: stloc.3 + IL_0018: ldloc.2 + IL_0019: ldarg.2 + IL_001a: add + IL_001b: stloc.s V_4 + IL_001d: ldloc.2 + IL_001e: ldloc.3 + IL_001f: add + IL_0020: ldloc.s V_4 + IL_0022: add + IL_0023: stelem.i4 + IL_0024: ldloc.1 + IL_0025: ldc.i4.1 + IL_0026: add + IL_0027: stloc.1 + IL_0028: ldloc.1 + IL_0029: ldloc.0 + IL_002a: ldlen + IL_002b: conv.i4 + IL_002c: blt.s IL_000e + + IL_002e: ldloc.0 + IL_002f: ret + } + + .method public static int32[] f0000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2, + int32 V_3, + int32 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_0030 + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldarg.1 + IL_0015: ldnull + IL_0016: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001b: pop + IL_001c: ldloc.2 + IL_001d: ldarg.2 + IL_001e: add + IL_001f: stloc.3 + IL_0020: ldloc.2 + IL_0021: ldarg.3 + IL_0022: add + IL_0023: stloc.s V_4 + IL_0025: ldloc.2 + IL_0026: ldloc.3 + IL_0027: add + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: stelem.i4 + IL_002c: ldloc.1 + IL_002d: ldc.i4.1 + IL_002e: add + IL_002f: stloc.1 + IL_0030: ldloc.1 + IL_0031: ldloc.0 + IL_0032: ldlen + IL_0033: conv.i4 + IL_0034: blt.s IL_000e + + IL_0036: ldloc.0 + IL_0037: ret + } + + .method public static int32[] f00000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2, + int32 V_3, + int32 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_0030 + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: ldarg.2 + IL_0016: add + IL_0017: stloc.3 + IL_0018: ldarg.1 + IL_0019: ldnull + IL_001a: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001f: pop + IL_0020: ldloc.2 + IL_0021: ldarg.3 + IL_0022: add + IL_0023: stloc.s V_4 + IL_0025: ldloc.2 + IL_0026: ldloc.3 + IL_0027: add + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: stelem.i4 + IL_002c: ldloc.1 + IL_002d: ldc.i4.1 + IL_002e: add + IL_002f: stloc.1 + IL_0030: ldloc.1 + IL_0031: ldloc.0 + IL_0032: ldlen + IL_0033: conv.i4 + IL_0034: blt.s IL_000e + + IL_0036: ldloc.0 + IL_0037: ret + } + + .method public static int32[] f000000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 6 + .locals init (int32[] V_0, + int32 V_1, + int32 V_2, + int32 V_3, + int32 V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldlen + IL_0003: conv.i4 + IL_0004: newarr [runtime]System.Int32 + IL_0009: stloc.0 + IL_000a: ldc.i4.0 + IL_000b: stloc.1 + IL_000c: br.s IL_0030 + + IL_000e: ldloc.0 + IL_000f: ldloc.1 + IL_0010: ldarg.0 + IL_0011: ldloc.1 + IL_0012: ldelem.i4 + IL_0013: stloc.2 + IL_0014: ldloc.2 + IL_0015: ldarg.2 + IL_0016: add + IL_0017: stloc.3 + IL_0018: ldloc.2 + IL_0019: ldarg.3 + IL_001a: add + IL_001b: stloc.s V_4 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: pop + IL_0025: ldloc.2 + IL_0026: ldloc.3 + IL_0027: add + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: stelem.i4 + IL_002c: ldloc.1 + IL_002d: ldc.i4.1 + IL_002e: add + IL_002f: stloc.1 + IL_0030: ldloc.1 + IL_0031: ldloc.0 + IL_0032: ldlen + IL_0033: conv.i4 + IL_0034: blt.s IL_000e + + IL_0036: ldloc.0 + IL_0037: ret + } + + .method public static int32[] f0000000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0063: ret + } + .method public static int32[] f1(int32[] 'array') cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs index fb12ad5c4de..d38f83502e8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs @@ -1,4 +1,15 @@ -let f1 (array: int array) = [for x in array -> x] +let f0 (array: int array) = [for x in array do x] +let f00 (array: int array) = [for x in array do yield x] +let f000 (array: int array) = [for x in array do let x = x in yield x] +let f0000 (array: int array) = [for x in array do let x = x in x] +let f00000 (array: int array) x y = [for z in array do let foo = z + x in let bar = z + y in yield z + foo + bar] +let f000000 (array: int array) x y = [for z in array do let foo = z + x in let bar = z + y in z + foo + bar] +let f0000000 (array: int array) f x y = [for z in array do f (); let foo = z + x in let bar = z + y in z + foo + bar] +let f00000000 (array: int array) f x y = [for z in array do let foo = z + x in f (); let bar = z + y in z + foo + bar] +let f000000000 (array: int array) f x y = [for z in array do let foo = z + x in let bar = z + y in f (); z + foo + bar] +let f0000000000 (array: int array) (f : unit -> int) x y = [for z in array do let foo = z + x in let bar = z + y in f (); z + foo + bar] + +let f1 (array: int array) = [for x in array -> x] let f2 f (array: int array) = [for x in array -> f x] let f3 f (array: int array) = [for x in array -> f (); x] let f4 f g (array: int array) = [for x in array -> f (); g(); x] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs.il.bsl index 043ab7f4cff..c649f2e871e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInArray_ToList.fs.il.bsl @@ -43,6 +43,673 @@ 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 static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0(int32[] 'array') cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f00(int32[] 'array') cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f000(int32[] 'array') cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001b + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: nop + IL_0012: ldloca.s V_0 + IL_0014: ldloc.3 + IL_0015: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001a: nop + IL_001b: ldloc.1 + IL_001c: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0021: brtrue.s IL_000a + + IL_0023: ldnull + IL_0024: stloc.2 + IL_0025: leave.s IL_003c + + } + finally + { + IL_0027: ldloc.1 + IL_0028: isinst [runtime]System.IDisposable + IL_002d: stloc.s V_4 + IL_002f: ldloc.s V_4 + IL_0031: brfalse.s IL_003b + + IL_0033: ldloc.s V_4 + IL_0035: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_003a: endfinally + IL_003b: endfinally + } + IL_003c: ldloc.2 + IL_003d: pop + IL_003e: ldloca.s V_0 + IL_0040: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0045: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0000(int32[] 'array') cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000(int32[] 'array', + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0054: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000(int32[] 'array', + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0054: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldarg.1 + IL_0012: ldnull + IL_0013: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0018: pop + IL_0019: ldloc.3 + IL_001a: ldarg.2 + IL_001b: add + IL_001c: stloc.s V_4 + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldarg.1 + IL_0017: ldnull + IL_0018: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001d: pop + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldarg.1 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: pop + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000000(int32[] 'array', + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0063: ret + } + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f1(int32[] 'array') cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs index 62b7b9bc6c0..9a19aa234f8 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs @@ -1,4 +1,15 @@ -let f1 (list: int list) = [|for x in list -> x|] +let f0 (list: int list) = [|for x in list do x|] +let f00 (list: int list) = [|for x in list do yield x|] +let f000 (list: int list) = [|for x in list do let x = x in yield x|] +let f0000 (list: int list) = [|for x in list do let x = x in x|] +let f00000 (list: int list) x y = [|for z in list do let foo = z + x in let bar = z + y in yield z + foo + bar|] +let f000000 (list: int list) x y = [|for z in list do let foo = z + x in let bar = z + y in z + foo + bar|] +let f0000000 (list: int list) f x y = [|for z in list do f (); let foo = z + x in let bar = z + y in z + foo + bar|] +let f00000000 (list: int list) f x y = [|for z in list do let foo = z + x in f (); let bar = z + y in z + foo + bar|] +let f000000000 (list: int list) f x y = [|for z in list do let foo = z + x in let bar = z + y in f (); z + foo + bar|] +let f0000000000 (list: int list) (f : unit -> int) x y = [|for z in list do let foo = z + x in let bar = z + y in f (); z + foo + bar|] + +let f1 (list: int list) = [|for x in list -> x|] let f2 f (list: int list) = [|for x in list -> f x|] let f3 f (list: int list) = [|for x in list -> f (); x|] let f4 f g (list: int list) = [|for x in list -> f (); g(); x|] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs.il.bsl index 2dcd11c67c8..2c0d8191dfb 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToArray.fs.il.bsl @@ -43,6 +43,667 @@ 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 static int32[] f0(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f00(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001b + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: nop + IL_0012: ldloca.s V_0 + IL_0014: ldloc.3 + IL_0015: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_001a: nop + IL_001b: ldloc.1 + IL_001c: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0021: brtrue.s IL_000a + + IL_0023: ldnull + IL_0024: stloc.2 + IL_0025: leave.s IL_003c + + } + finally + { + IL_0027: ldloc.1 + IL_0028: isinst [runtime]System.IDisposable + IL_002d: stloc.s V_4 + IL_002f: ldloc.s V_4 + IL_0031: brfalse.s IL_003b + + IL_0033: ldloc.s V_4 + IL_0035: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_003a: endfinally + IL_003b: endfinally + } + IL_003c: ldloc.2 + IL_003d: pop + IL_003e: ldloca.s V_0 + IL_0040: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0045: ret + } + + .method public static int32[] f0000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f00000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0054: ret + } + + .method public static int32[] f000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0054: ret + } + + .method public static int32[] f0000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldarg.1 + IL_0012: ldnull + IL_0013: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0018: pop + IL_0019: ldloc.3 + IL_001a: ldarg.2 + IL_001b: add + IL_001c: stloc.s V_4 + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f00000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldarg.1 + IL_0017: ldnull + IL_0018: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001d: pop + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f000000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldarg.1 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: pop + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f0000000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0063: ret + } + .method public static int32[] f1(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs index cfbb0fb567f..6174b901ff0 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs @@ -1,4 +1,15 @@ -let f1 (list: int list) = [for x in list -> x] +let f0 (list: int list) = [for x in list do x] +let f00 (list: int list) = [for x in list do yield x] +let f000 (list: int list) = [for x in list do let x = x in yield x] +let f0000 (list: int list) = [for x in list do let x = x in x] +let f00000 (list: int list) x y = [for z in list do let foo = z + x in let bar = z + y in yield z + foo + bar] +let f000000 (list: int list) x y = [for z in list do let foo = z + x in let bar = z + y in z + foo + bar] +let f0000000 (list: int list) f x y = [for z in list do f (); let foo = z + x in let bar = z + y in z + foo + bar] +let f00000000 (list: int list) f x y = [for z in list do let foo = z + x in f (); let bar = z + y in z + foo + bar] +let f000000000 (list: int list) f x y = [for z in list do let foo = z + x in let bar = z + y in f (); z + foo + bar] +let f0000000000 (list: int list) (f : unit -> int) x y = [for z in list do let foo = z + x in let bar = z + y in f (); z + foo + bar] + +let f1 (list: int list) = [for x in list -> x] let f2 f (list: int list) = [for x in list -> f x] let f3 f (list: int list) = [for x in list -> f (); x] let f4 f g (list: int list) = [for x in list -> f (); g(); x] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs.il.bsl index e370fcd5fbf..f70400c2792 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInList_ToList.fs.il.bsl @@ -43,6 +43,521 @@ 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 static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0025 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001b: nop + IL_001c: ldloc.2 + IL_001d: stloc.1 + IL_001e: ldloc.1 + IL_001f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0024: stloc.2 + IL_0025: ldloc.2 + IL_0026: brtrue.s IL_000c + + IL_0028: ldloca.s V_0 + IL_002a: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_002f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f00(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0025 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001b: nop + IL_001c: ldloc.2 + IL_001d: stloc.1 + IL_001e: ldloc.1 + IL_001f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0024: stloc.2 + IL_0025: ldloc.2 + IL_0026: brtrue.s IL_000c + + IL_0028: ldloca.s V_0 + IL_002a: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_002f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0026 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: nop + IL_0016: ldloc.3 + IL_0017: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001c: nop + IL_001d: ldloc.2 + IL_001e: stloc.1 + IL_001f: ldloc.1 + IL_0020: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0025: stloc.2 + IL_0026: ldloc.2 + IL_0027: brtrue.s IL_000c + + IL_0029: ldloca.s V_0 + IL_002b: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0030: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0026 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: nop + IL_0016: ldloc.3 + IL_0017: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001c: nop + IL_001d: ldloc.2 + IL_001e: stloc.1 + IL_001f: ldloc.1 + IL_0020: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0025: stloc.2 + IL_0026: ldloc.2 + IL_0027: brtrue.s IL_000c + + IL_0029: ldloca.s V_0 + IL_002b: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0030: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0035 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: ldarg.1 + IL_0017: add + IL_0018: stloc.s V_4 + IL_001a: ldloc.3 + IL_001b: ldarg.2 + IL_001c: add + IL_001d: stloc.s V_5 + IL_001f: ldloc.3 + IL_0020: ldloc.s V_4 + IL_0022: add + IL_0023: ldloc.s V_5 + IL_0025: add + IL_0026: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_002b: nop + IL_002c: ldloc.2 + IL_002d: stloc.1 + IL_002e: ldloc.1 + IL_002f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0034: stloc.2 + IL_0035: ldloc.2 + IL_0036: brtrue.s IL_000c + + IL_0038: ldloca.s V_0 + IL_003a: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_003f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_0035 + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: ldarg.1 + IL_0017: add + IL_0018: stloc.s V_4 + IL_001a: ldloc.3 + IL_001b: ldarg.2 + IL_001c: add + IL_001d: stloc.s V_5 + IL_001f: ldloc.3 + IL_0020: ldloc.s V_4 + IL_0022: add + IL_0023: ldloc.s V_5 + IL_0025: add + IL_0026: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_002b: nop + IL_002c: ldloc.2 + IL_002d: stloc.1 + IL_002e: ldloc.1 + IL_002f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0034: stloc.2 + IL_0035: ldloc.2 + IL_0036: brtrue.s IL_000c + + IL_0038: ldloca.s V_0 + IL_003a: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_003f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_003d + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldarg.1 + IL_0016: ldnull + IL_0017: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001c: pop + IL_001d: ldloc.3 + IL_001e: ldarg.2 + IL_001f: add + IL_0020: stloc.s V_4 + IL_0022: ldloc.3 + IL_0023: ldarg.3 + IL_0024: add + IL_0025: stloc.s V_5 + IL_0027: ldloc.3 + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: ldloc.s V_5 + IL_002d: add + IL_002e: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0033: nop + IL_0034: ldloc.2 + IL_0035: stloc.1 + IL_0036: ldloc.1 + IL_0037: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: brtrue.s IL_000c + + IL_0040: ldloca.s V_0 + IL_0042: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0047: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_003d + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: ldarg.2 + IL_0017: add + IL_0018: stloc.s V_4 + IL_001a: ldarg.1 + IL_001b: ldnull + IL_001c: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0021: pop + IL_0022: ldloc.3 + IL_0023: ldarg.3 + IL_0024: add + IL_0025: stloc.s V_5 + IL_0027: ldloc.3 + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: ldloc.s V_5 + IL_002d: add + IL_002e: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0033: nop + IL_0034: ldloc.2 + IL_0035: stloc.1 + IL_0036: ldloc.1 + IL_0037: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: brtrue.s IL_000c + + IL_0040: ldloca.s V_0 + IL_0042: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0047: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_1, + class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: stloc.1 + IL_0003: ldloc.1 + IL_0004: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_0009: stloc.2 + IL_000a: br.s IL_003d + + IL_000c: ldloc.1 + IL_000d: call instance !0 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_HeadOrDefault() + IL_0012: stloc.3 + IL_0013: ldloca.s V_0 + IL_0015: ldloc.3 + IL_0016: ldarg.2 + IL_0017: add + IL_0018: stloc.s V_4 + IL_001a: ldloc.3 + IL_001b: ldarg.3 + IL_001c: add + IL_001d: stloc.s V_5 + IL_001f: ldarg.1 + IL_0020: ldnull + IL_0021: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0026: pop + IL_0027: ldloc.3 + IL_0028: ldloc.s V_4 + IL_002a: add + IL_002b: ldloc.s V_5 + IL_002d: add + IL_002e: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0033: nop + IL_0034: ldloc.2 + IL_0035: stloc.1 + IL_0036: ldloc.1 + IL_0037: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_TailOrNull() + IL_003c: stloc.2 + IL_003d: ldloc.2 + IL_003e: brtrue.s IL_000c + + IL_0040: ldloca.s V_0 + IL_0042: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0047: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000000(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0063: ret + } + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f1(class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 list) cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs index f4a28b47626..2e1f8870f6e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs @@ -1,4 +1,15 @@ -let f1 (seq: int seq) = [|for x in seq -> x|] +let f0 (seq: int seq) = [|for x in seq do x|] +let f00 (seq: int seq) = [|for x in seq do yield x|] +let f000 (seq: int seq) = [|for x in seq do let x = x in yield x|] +let f0000 (seq: int seq) = [|for x in seq do let x = x in x|] +let f00000 (seq: int seq) x y = [|for z in seq do let foo = z + x in let bar = z + y in yield z + foo + bar|] +let f000000 (seq: int seq) x y = [|for z in seq do let foo = z + x in let bar = z + y in z + foo + bar|] +let f0000000 (seq: int seq) f x y = [|for z in seq do f (); let foo = z + x in let bar = z + y in z + foo + bar|] +let f00000000 (seq: int seq) f x y = [|for z in seq do let foo = z + x in f (); let bar = z + y in z + foo + bar|] +let f000000000 (seq: int seq) f x y = [|for z in seq do let foo = z + x in let bar = z + y in f (); z + foo + bar|] +let f0000000000 (seq: int seq) (f : unit -> int) x y = [|for z in seq do let foo = z + x in let bar = z + y in f (); z + foo + bar|] + +let f1 (seq: int seq) = [|for x in seq -> x|] let f2 f (seq: int seq) = [|for x in seq -> f x|] let f3 f (seq: int seq) = [|for x in seq -> f (); x|] let f4 f g (seq: int seq) = [|for x in seq -> f (); g(); x|] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs.il.bsl index ebd87c0f0f9..6252744297b 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToArray.fs.il.bsl @@ -43,6 +43,667 @@ 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 static int32[] f0(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f00(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f000(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001b + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: nop + IL_0012: ldloca.s V_0 + IL_0014: ldloc.3 + IL_0015: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_001a: nop + IL_001b: ldloc.1 + IL_001c: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0021: brtrue.s IL_000a + + IL_0023: ldnull + IL_0024: stloc.2 + IL_0025: leave.s IL_003c + + } + finally + { + IL_0027: ldloc.1 + IL_0028: isinst [runtime]System.IDisposable + IL_002d: stloc.s V_4 + IL_002f: ldloc.s V_4 + IL_0031: brfalse.s IL_003b + + IL_0033: ldloc.s V_4 + IL_0035: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_003a: endfinally + IL_003b: endfinally + } + IL_003c: ldloc.2 + IL_003d: pop + IL_003e: ldloca.s V_0 + IL_0040: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0045: ret + } + + .method public static int32[] f0000(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0044: ret + } + + .method public static int32[] f00000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0054: ret + } + + .method public static int32[] f000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0054: ret + } + + .method public static int32[] f0000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldarg.1 + IL_0012: ldnull + IL_0013: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0018: pop + IL_0019: ldloc.3 + IL_001a: ldarg.2 + IL_001b: add + IL_001c: stloc.s V_4 + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f00000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldarg.1 + IL_0017: ldnull + IL_0018: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001d: pop + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f000000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldarg.1 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: pop + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_005c: ret + } + + .method public static int32[] f0000000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance !0[] valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ArrayCollector`1::Close() + IL_0063: ret + } + .method public static int32[] f1(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed { diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs index 9c88ace26d3..8368f875244 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs @@ -1,4 +1,15 @@ -let f1 (seq: int seq) = [for x in seq -> x] +let f0 (seq: int seq) = [for x in seq do x] +let f00 (seq: int seq) = [for x in seq do yield x] +let f000 (seq: int seq) = [for x in seq do let x = x in yield x] +let f0000 (seq: int seq) = [for x in seq do let x = x in x] +let f00000 (seq: int seq) x y = [for z in seq do let foo = z + x in let bar = z + y in yield z + foo + bar] +let f000000 (seq: int seq) x y = [for z in seq do let foo = z + x in let bar = z + y in z + foo + bar] +let f0000000 (seq: int seq) f x y = [for z in seq do f (); let foo = z + x in let bar = z + y in z + foo + bar] +let f00000000 (seq: int seq) f x y = [for z in seq do let foo = z + x in f (); let bar = z + y in z + foo + bar] +let f000000000 (seq: int seq) f x y = [for z in seq do let foo = z + x in let bar = z + y in f (); z + foo + bar] +let f0000000000 (seq: int seq) (f : unit -> int) x y = [for z in seq do let foo = z + x in let bar = z + y in f (); z + foo + bar] + +let f1 (seq: int seq) = [for x in seq -> x] let f2 f (seq: int seq) = [for x in seq -> f x] let f3 f (seq: int seq) = [for x in seq -> f (); x] let f4 f g (seq: int seq) = [for x in seq -> f (); g(); x] diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs.il.bsl index 8f884f2b4fe..8c563e0be23 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/ComputedCollections/ForXInSeq_ToList.fs.il.bsl @@ -43,6 +43,673 @@ 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 static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f00(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f000(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001b + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: nop + IL_0012: ldloca.s V_0 + IL_0014: ldloc.3 + IL_0015: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_001a: nop + IL_001b: ldloc.1 + IL_001c: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0021: brtrue.s IL_000a + + IL_0023: ldnull + IL_0024: stloc.2 + IL_0025: leave.s IL_003c + + } + finally + { + IL_0027: ldloc.1 + IL_0028: isinst [runtime]System.IDisposable + IL_002d: stloc.s V_4 + IL_002f: ldloc.s V_4 + IL_0031: brfalse.s IL_003b + + IL_0033: ldloc.s V_4 + IL_0035: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_003a: endfinally + IL_003b: endfinally + } + IL_003c: ldloc.2 + IL_003d: pop + IL_003e: ldloca.s V_0 + IL_0040: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0045: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f0000(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed + { + + .maxstack 4 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + class [runtime]System.IDisposable V_4) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_001a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloca.s V_0 + IL_0013: ldloc.3 + IL_0014: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0019: nop + IL_001a: ldloc.1 + IL_001b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0020: brtrue.s IL_000a + + IL_0022: ldnull + IL_0023: stloc.2 + IL_0024: leave.s IL_003b + + } + finally + { + IL_0026: ldloc.1 + IL_0027: isinst [runtime]System.IDisposable + IL_002c: stloc.s V_4 + IL_002e: ldloc.s V_4 + IL_0030: brfalse.s IL_003a + + IL_0032: ldloc.s V_4 + IL_0034: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0039: endfinally + IL_003a: endfinally + } + IL_003b: ldloc.2 + IL_003c: pop + IL_003d: ldloca.s V_0 + IL_003f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0044: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0054: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 03 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_002a + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.1 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.2 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldloc.3 + IL_001e: ldloc.s V_4 + IL_0020: add + IL_0021: ldloc.s V_5 + IL_0023: add + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloc.1 + IL_002b: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0030: brtrue.s IL_000a + + IL_0032: ldnull + IL_0033: stloc.2 + IL_0034: leave.s IL_004b + + } + finally + { + IL_0036: ldloc.1 + IL_0037: isinst [runtime]System.IDisposable + IL_003c: stloc.s V_6 + IL_003e: ldloc.s V_6 + IL_0040: brfalse.s IL_004a + + IL_0042: ldloc.s V_6 + IL_0044: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0049: endfinally + IL_004a: endfinally + } + IL_004b: ldloc.2 + IL_004c: pop + IL_004d: ldloca.s V_0 + IL_004f: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0054: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldarg.1 + IL_0012: ldnull + IL_0013: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0018: pop + IL_0019: ldloc.3 + IL_001a: ldarg.2 + IL_001b: add + IL_001c: stloc.s V_4 + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f00000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldarg.1 + IL_0017: ldnull + IL_0018: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_001d: pop + IL_001e: ldloc.3 + IL_001f: ldarg.3 + IL_0020: add + IL_0021: stloc.s V_5 + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f000000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0032 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldarg.1 + IL_001c: ldnull + IL_001d: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0022: pop + IL_0023: ldloca.s V_0 + IL_0025: ldloc.3 + IL_0026: ldloc.s V_4 + IL_0028: add + IL_0029: ldloc.s V_5 + IL_002b: add + IL_002c: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0031: nop + IL_0032: ldloc.1 + IL_0033: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_0038: brtrue.s IL_000a + + IL_003a: ldnull + IL_003b: stloc.2 + IL_003c: leave.s IL_0053 + + } + finally + { + IL_003e: ldloc.1 + IL_003f: isinst [runtime]System.IDisposable + IL_0044: stloc.s V_6 + IL_0046: ldloc.s V_6 + IL_0048: brfalse.s IL_0052 + + IL_004a: ldloc.s V_6 + IL_004c: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0051: endfinally + IL_0052: endfinally + } + IL_0053: ldloc.2 + IL_0054: pop + IL_0055: ldloca.s V_0 + IL_0057: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_005c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + f0000000000(class [runtime]System.Collections.Generic.IEnumerable`1 seq, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 f, + int32 x, + int32 y) cil managed + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationArgumentCountsAttribute::.ctor(int32[]) = ( 01 00 04 00 00 00 01 00 00 00 01 00 00 00 01 00 + 00 00 01 00 00 00 00 00 ) + + .maxstack 5 + .locals init (valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1 V_0, + class [runtime]System.Collections.Generic.IEnumerator`1 V_1, + class [runtime]System.Collections.Generic.IEnumerable`1 V_2, + int32 V_3, + int32 V_4, + int32 V_5, + class [runtime]System.IDisposable V_6) + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: callvirt instance class [runtime]System.Collections.Generic.IEnumerator`1 class [runtime]System.Collections.Generic.IEnumerable`1::GetEnumerator() + IL_0007: stloc.1 + .try + { + IL_0008: br.s IL_0039 + + IL_000a: ldloc.1 + IL_000b: callvirt instance !0 class [runtime]System.Collections.Generic.IEnumerator`1::get_Current() + IL_0010: stloc.3 + IL_0011: ldloc.3 + IL_0012: ldarg.2 + IL_0013: add + IL_0014: stloc.s V_4 + IL_0016: ldloc.3 + IL_0017: ldarg.3 + IL_0018: add + IL_0019: stloc.s V_5 + IL_001b: ldloca.s V_0 + IL_001d: ldarg.1 + IL_001e: ldnull + IL_001f: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0) + IL_0024: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0029: nop + IL_002a: ldloca.s V_0 + IL_002c: ldloc.3 + IL_002d: ldloc.s V_4 + IL_002f: add + IL_0030: ldloc.s V_5 + IL_0032: add + IL_0033: call instance void valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Add(!0) + IL_0038: nop + IL_0039: ldloc.1 + IL_003a: callvirt instance bool [runtime]System.Collections.IEnumerator::MoveNext() + IL_003f: brtrue.s IL_000a + + IL_0041: ldnull + IL_0042: stloc.2 + IL_0043: leave.s IL_005a + + } + finally + { + IL_0045: ldloc.1 + IL_0046: isinst [runtime]System.IDisposable + IL_004b: stloc.s V_6 + IL_004d: ldloc.s V_6 + IL_004f: brfalse.s IL_0059 + + IL_0051: ldloc.s V_6 + IL_0053: callvirt instance void [runtime]System.IDisposable::Dispose() + IL_0058: endfinally + IL_0059: endfinally + } + IL_005a: ldloc.2 + IL_005b: pop + IL_005c: ldloca.s V_0 + IL_005e: call instance class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 valuetype [FSharp.Core]Microsoft.FSharp.Core.CompilerServices.ListCollector`1::Close() + IL_0063: ret + } + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 f1(class [runtime]System.Collections.Generic.IEnumerable`1 seq) cil managed { From 6a828e25cee71c87f56854224461d8b0ba6d3c2d Mon Sep 17 00:00:00 2001 From: Brian Rourke Boll Date: Sat, 27 Jul 2024 13:51:32 -0400 Subject: [PATCH 5/7] Prefix-to-infix code fix: don't throw if error range extends to EOF (#17448) --- docs/release-notes/.VisualStudio/17.12.md | 2 ++ .../ChangePrefixNegationToInfixSubtraction.fs | 32 ++++++++++--------- ...gePrefixNegationToInfixSubtractionTests.fs | 20 ++++++++++++ 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/docs/release-notes/.VisualStudio/17.12.md b/docs/release-notes/.VisualStudio/17.12.md index c247da5870b..6df973cf607 100644 --- a/docs/release-notes/.VisualStudio/17.12.md +++ b/docs/release-notes/.VisualStudio/17.12.md @@ -1,5 +1,7 @@ ### Fixed +* In the prefix-to-infix code fix, don't throw an exception if the error range for FS0003 extends through the end of the source text. ([PR #17448](https://github.com/dotnet/fsharp/pull/17448)) + ### Added ### Changed diff --git a/vsintegration/src/FSharp.Editor/CodeFixes/ChangePrefixNegationToInfixSubtraction.fs b/vsintegration/src/FSharp.Editor/CodeFixes/ChangePrefixNegationToInfixSubtraction.fs index 87841d5d57b..ee8b8870538 100644 --- a/vsintegration/src/FSharp.Editor/CodeFixes/ChangePrefixNegationToInfixSubtraction.fs +++ b/vsintegration/src/FSharp.Editor/CodeFixes/ChangePrefixNegationToInfixSubtraction.fs @@ -18,10 +18,13 @@ type internal ChangePrefixNegationToInfixSubtractionCodeFixProvider() = static let title = SR.ChangePrefixNegationToInfixSubtraction() static let rec findNextNonWhitespacePos (sourceText: SourceText) pos = - if pos < sourceText.Length && Char.IsWhiteSpace sourceText[pos] then - findNextNonWhitespacePos sourceText (pos + 1) + if pos < sourceText.Length - 1 then + if Char.IsWhiteSpace sourceText[pos] then + findNextNonWhitespacePos sourceText (pos + 1) + else + ValueSome pos else - pos + ValueNone override _.FixableDiagnosticIds = ImmutableArray.Create "FS0003" @@ -34,16 +37,15 @@ type internal ChangePrefixNegationToInfixSubtractionCodeFixProvider() = // in a line like "... x -1 ...", // squiggly goes for "x", not for "-", hence we search for "-" - let pos = findNextNonWhitespacePos sourceText (context.Span.End + 1) - - if sourceText[pos] <> '-' then - return ValueNone - else - return - ValueSome - { - Name = CodeFix.ChangePrefixNegationToInfixSubtraction - Message = title - Changes = [ TextChange(TextSpan(pos + 1, 0), " ") ] - } + let fix = + findNextNonWhitespacePos sourceText (context.Span.End + 1) + |> ValueOption.filter (fun pos -> sourceText[pos] = '-') + |> ValueOption.map (fun pos -> + { + Name = CodeFix.ChangePrefixNegationToInfixSubtraction + Message = title + Changes = [ TextChange(TextSpan(pos + 1, 0), " ") ] + }) + + return fix } diff --git a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ChangePrefixNegationToInfixSubtractionTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ChangePrefixNegationToInfixSubtractionTests.fs index 5245d8a3ae0..b93055a3a90 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ChangePrefixNegationToInfixSubtractionTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CodeFixes/ChangePrefixNegationToInfixSubtractionTests.fs @@ -48,3 +48,23 @@ let x = 1 (+) 2 let actual = codeFix |> tryFix code Auto Assert.Equal(expected, actual) + +[] +let ``Doesn't throw when the error range extends to the end of the source text`` () = + let code = + """ +module Microsoft = + module FSharp = + module Core = + module LanguagePrimitives = + module IntrinsicFunctions = + let GetArray2D _ _ = 99 + +let a = Array2D.init 10 10 (+) +a[5, 5]""" + + let expected = None + + let actual = codeFix |> tryFix code Auto + + Assert.Equal(expected, actual) From 3dbbcc7deb8415bb1078facd1d506ab16e425ade Mon Sep 17 00:00:00 2001 From: Petr Date: Sat, 27 Jul 2024 19:53:40 +0200 Subject: [PATCH 6/7] Skip another flaky test (#17441) --- .../CompilerService/AsyncMemoize.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs index d4d901b050b..a1cc9169c1d 100644 --- a/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs +++ b/tests/FSharp.Compiler.ComponentTests/CompilerService/AsyncMemoize.fs @@ -249,7 +249,7 @@ let ``Job is restarted if first requestor cancels but keeps running if second re type ExpectedException() = inherit Exception() -[] +[] let ``Stress test`` () = let seed = System.Random().Next() From aa2a9e1d5bb9b4fb58a7183923cd3bc00e5e8a62 Mon Sep 17 00:00:00 2001 From: Alex Berezhnykh Date: Sun, 28 Jul 2024 01:08:33 +0300 Subject: [PATCH 7/7] Optimize metadata members and custom attributes reading (#17364) * wip * wip * cleanup * formatting * release notes * release notes --------- Co-authored-by: Petr Co-authored-by: Vlad Zarytovskii --- .../.FSharp.Compiler.Service/9.0.100.md | 1 + src/Compiler/AbstractIL/ilread.fs | 74 ++++++++++++------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md index 9a65849c833..1166f8b413e 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.100.md @@ -12,6 +12,7 @@ * Change compiler default setting realsig+ when building assemblies ([Issue #17384](https://github.com/dotnet/fsharp/issues/17384), [PR #17378](https://github.com/dotnet/fsharp/pull/17385)) * Change compiler default setting for compressedMetadata ([Issue #17379](https://github.com/dotnet/fsharp/issues/17379), [PR #17383](https://github.com/dotnet/fsharp/pull/17383)) +* Optimize metadata reading for type members and custom attributes. ([PR #17364](https://github.com/dotnet/fsharp/pull/17364)) * Enforce `AttributeTargets` on unions. ([PR #17389](https://github.com/dotnet/fsharp/pull/17389)) ### Breaking Changes diff --git a/src/Compiler/AbstractIL/ilread.fs b/src/Compiler/AbstractIL/ilread.fs index 17b97c5e9c2..7628df6311b 100644 --- a/src/Compiler/AbstractIL/ilread.fs +++ b/src/Compiler/AbstractIL/ilread.fs @@ -883,7 +883,7 @@ let tomdCompare (TaggedIndex(t1: TypeOrMethodDefTag, idx1)) (TaggedIndex(t2: Typ elif idx1 > idx2 then 1 else compare t1.Tag t2.Tag -let simpleIndexCompare (idx1: int) (idx2: int) = compare idx1 idx2 +let inline simpleIndexCompare (idx1: int) (idx2: int) = compare idx1 idx2 //--------------------------------------------------------------------- // The various keys for the various caches. @@ -2314,6 +2314,8 @@ and seekReadTypeDefAsTypeUncached ctxtH (TypeDefAsTypIdx(boxity, ginst, idx)) = mkILTy boxity (ILTypeSpec.Create(seekReadTypeDefAsTypeRef ctxt idx, ginst)) and seekReadTypeDefAsTypeRef (ctxt: ILMetadataReader) idx = + let mdv = ctxt.mdfile.GetView() + let enc = if seekIsTopTypeDefOfIdx ctxt idx then [] @@ -2321,11 +2323,14 @@ and seekReadTypeDefAsTypeRef (ctxt: ILMetadataReader) idx = let enclIdx = seekReadIndexedRow ( ctxt.getNumRows TableNames.Nested, - seekReadNestedRow ctxt, - fst, - simpleIndexCompare idx, + id, + id, + (fun i -> + let mutable addr = ctxt.rowAddr TableNames.Nested i + let nestedIdx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + simpleIndexCompare idx nestedIdx), isSorted ctxt TableNames.Nested, - snd + (fun i -> seekReadNestedRow ctxt i |> snd) ) let tref = seekReadTypeDefAsTypeRef ctxt enclIdx @@ -3086,15 +3091,18 @@ and seekReadMethodImpls (ctxt: ILMetadataReader) numTypars tidx = let mimpls = seekReadIndexedRows ( ctxt.getNumRows TableNames.MethodImpl, - seekReadMethodImplRow ctxt mdv, - (fun (a, _, _) -> a), - simpleIndexCompare tidx, + id, + id, + (fun i -> + let mutable addr = ctxt.rowAddr TableNames.MethodImpl i + let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + simpleIndexCompare tidx _tidx), isSorted ctxt TableNames.MethodImpl, - (fun (_, b, c) -> b, c) + seekReadMethodImplRow ctxt mdv ) mimpls - |> List.map (fun (b, c) -> + |> List.map (fun (_, b, c) -> { OverrideBy = let (MethodData(enclTy, cc, nm, argTys, retTy, methInst)) = @@ -3163,11 +3171,14 @@ and seekReadEvents (ctxt: ILMetadataReader) numTypars tidx = match seekReadOptionalIndexedRow ( ctxt.getNumRows TableNames.EventMap, - (fun i -> i, seekReadEventMapRow ctxt mdv i), - (fun (_, row) -> fst row), - compare tidx, + id, + id, + (fun i -> + let mutable addr = ctxt.rowAddr TableNames.EventMap i + let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + simpleIndexCompare tidx _tidx), false, - (fun (i, row) -> (i, snd row)) + (fun i -> i, seekReadEventMapRow ctxt mdv i |> snd) ) with | None -> [] @@ -3230,11 +3241,14 @@ and seekReadProperties (ctxt: ILMetadataReader) numTypars tidx = match seekReadOptionalIndexedRow ( ctxt.getNumRows TableNames.PropertyMap, - (fun i -> i, seekReadPropertyMapRow ctxt mdv i), - (fun (_, row) -> fst row), - compare tidx, + id, + id, + (fun i -> + let mutable addr = ctxt.rowAddr TableNames.PropertyMap i + let _tidx = seekReadUntaggedIdx TableNames.TypeDef ctxt mdv &addr + simpleIndexCompare tidx _tidx), false, - (fun (i, row) -> (i, snd row)) + (fun i -> i, seekReadPropertyMapRow ctxt mdv i |> snd) ) with | None -> [] @@ -3258,16 +3272,22 @@ and customAttrsReader ctxtH tag : ILAttributesStored = let (ctxt: ILMetadataReader) = getHole ctxtH let mdv = ctxt.mdfile.GetView() - let reader = - { new ISeekReadIndexedRowReader, ILAttribute> with - member _.GetRow(i, row) = - seekReadCustomAttributeRow ctxt mdv i &row - - member _.GetKey(attrRow) = attrRow.parentIndex - - member _.CompareKey(key) = hcaCompare (TaggedIndex(tag, idx)) key + let searchedKey = TaggedIndex(tag, idx) - member _.ConvertRow(attrRow) = + let reader = + { new ISeekReadIndexedRowReader with + member _.GetRow(i, rowIndex) = rowIndex <- i + member _.GetKey(rowIndex) = rowIndex + + member _.CompareKey(rowIndex) = + let mutable addr = ctxt.rowAddr TableNames.CustomAttribute rowIndex + // read parentIndex + let key = seekReadHasCustomAttributeIdx ctxt mdv &addr + hcaCompare searchedKey key + + member _.ConvertRow(rowIndex) = + let mutable attrRow = Unchecked.defaultof<_> + seekReadCustomAttributeRow ctxt mdv rowIndex &attrRow seekReadCustomAttr ctxt (attrRow.typeIndex, attrRow.valueIndex) }