diff --git a/src/Compiler/Optimize/LowerComputedCollections.fs b/src/Compiler/Optimize/LowerComputedCollections.fs index 0d3fb3d70a7..9460c0be089 100644 --- a/src/Compiler/Optimize/LowerComputedCollections.fs +++ b/src/Compiler/Optimize/LowerComputedCollections.fs @@ -255,101 +255,321 @@ let (|SeqToArray|_|) g expr = | ValApp g g.seq_to_array_vref (_, [seqExpr], m) -> ValueSome (seqExpr, m) | _ -> ValueNone +/// Constant 0. +[] +let (|Zero|_|) expr = + match expr with + | Const.Zero + | Const.Int32 0 + | Const.Int64 0L + | Const.UInt64 0UL + | Const.UInt32 0u + | Const.IntPtr 0L + | Const.UIntPtr 0UL + | Const.Int16 0s + | Const.UInt16 0us + | Const.SByte 0y + | Const.Byte 0uy + | Const.Char '\000' -> ValueSome Zero + | _ -> ValueNone + +/// Constant 1. +[] +let (|One|_|) expr = + match expr with + | Const.Int32 1 + | Const.Int64 1L + | Const.UInt64 1UL + | Const.UInt32 1u + | Const.IntPtr 1L + | Const.UIntPtr 1UL + | Const.Int16 1s + | Const.UInt16 1us + | Const.SByte 1y + | Const.Byte 1uy + | Const.Char '\001' -> ValueSome One + | _ -> ValueNone + +/// Positive constant. +[] +let (|Positive|_|) expr = + match expr with + | Const.Int32 v when v > 0 -> ValueSome Positive + | Const.Int64 v when v > 0L -> ValueSome Positive + | Const.IntPtr v when v > 0L -> ValueSome Positive + | Const.Int16 v when v > 0s -> ValueSome Positive + | Const.SByte v when v > 0y -> ValueSome Positive + | Const.UInt64 v when v > 0UL -> ValueSome Positive + | Const.UInt32 v when v > 0u -> ValueSome Positive + | Const.UIntPtr v when v > 0UL -> ValueSome Positive + | Const.UInt16 v when v > 0us -> ValueSome Positive + | Const.Byte v when v > 0uy -> ValueSome Positive + | Const.Char v when v > '\000' -> ValueSome Positive + | _ -> ValueNone + /// start..finish +/// start..step..finish [] -let (|Int32Range|_|) g expr = +let (|IntegralRange|_|) g expr = match expr with - | ValApp g g.range_int32_op_vref ([], [start; Expr.Const (value = Const.Int32 1); finish], _) -> ValueSome (start, finish) + | ValApp g g.range_int32_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_int64_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_uint64_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_uint32_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_nativeint_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_unativeint_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_int16_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_uint16_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_sbyte_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_byte_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | ValApp g g.range_char_op_vref ([], [start; step; finish], _) -> ValueSome (start, step, finish) + | _ -> ValueNone + +/// 5..1 +/// 1..-5 +/// 1..-1..5 +/// 5..2..1 +[] +let (|EmptyRange|_|) (start, step, finish) = + match start, step, finish with + | Expr.Const (value = Const.Int32 start), Expr.Const (value = Const.Int32 step), Expr.Const (value = Const.Int32 finish) when finish < start && step > 0 || finish > start && step < 0 -> ValueSome EmptyRange + | Expr.Const (value = Const.Int64 start), Expr.Const (value = Const.Int64 step), Expr.Const (value = Const.Int64 finish) when finish < start && step > 0L || finish > start && step < 0L -> ValueSome EmptyRange + | Expr.Const (value = Const.UInt64 start), Expr.Const (value = Const.UInt64 _), Expr.Const (value = Const.UInt64 finish) when finish < start -> ValueSome EmptyRange + | Expr.Const (value = Const.UInt32 start), Expr.Const (value = Const.UInt32 _), Expr.Const (value = Const.UInt32 finish) when finish < start -> ValueSome EmptyRange + | Expr.Const (value = Const.IntPtr start), Expr.Const (value = Const.IntPtr step), Expr.Const (value = Const.IntPtr finish) when finish < start && step > 0L || finish > start && step < 0L -> ValueSome EmptyRange + | Expr.Const (value = Const.UIntPtr start), Expr.Const (value = Const.UIntPtr _), Expr.Const (value = Const.UIntPtr finish) when finish < start -> ValueSome EmptyRange + | Expr.Const (value = Const.Int16 start), Expr.Const (value = Const.Int16 step), Expr.Const (value = Const.Int16 finish) when finish < start && step > 0s || finish > start && step < 0s -> ValueSome EmptyRange + | Expr.Const (value = Const.UInt16 start), Expr.Const (value = Const.UInt16 _), Expr.Const (value = Const.UInt16 finish) when finish < start -> ValueSome EmptyRange + | Expr.Const (value = Const.SByte start), Expr.Const (value = Const.SByte step), Expr.Const (value = Const.SByte finish) when finish < start && step > 0y || finish > start && step < 0y -> ValueSome EmptyRange + | Expr.Const (value = Const.Byte start), Expr.Const (value = Const.Byte _), Expr.Const (value = Const.Byte finish) when finish < start -> ValueSome EmptyRange + | Expr.Const (value = Const.Char start), Expr.Const (value = Const.Char step), Expr.Const (value = Const.Char finish) when finish < start && step > '\000' || finish > start && step < '\000' -> ValueSome EmptyRange + | _ -> ValueNone + +/// 1..5 → (5 - 1) / 1 + 1 → 5 +/// 1..2..5 → (5 - 1) / 2 + 1 → 3 +/// -1..-2..-5 → (-5 - -1) / -2 + 1 → 3 +[] +let (|ConstCount|_|) (start, step, finish) = + match start, step, finish with + | Expr.Const (value = Const.Int32 start), Expr.Const (value = Const.Int32 step), Expr.Const (value = Const.Int32 finish) -> ValueSome (Const.Int32 ((finish - start) / step + 1)) + | Expr.Const (value = Const.Int64 start), Expr.Const (value = Const.Int64 step), Expr.Const (value = Const.Int64 finish) -> ValueSome (Const.Int64 ((finish - start) / step + 1L)) + | Expr.Const (value = Const.UInt64 start), Expr.Const (value = Const.UInt64 step), Expr.Const (value = Const.UInt64 finish) -> ValueSome (Const.UInt64 ((finish - start) / step + 1UL)) + | Expr.Const (value = Const.UInt32 start), Expr.Const (value = Const.UInt32 step), Expr.Const (value = Const.UInt32 finish) -> ValueSome (Const.UInt32 ((finish - start) / step + 1u)) + | Expr.Const (value = Const.IntPtr start), Expr.Const (value = Const.IntPtr step), Expr.Const (value = Const.IntPtr finish) -> ValueSome (Const.IntPtr ((finish - start) / step + 1L)) + | Expr.Const (value = Const.UIntPtr start), Expr.Const (value = Const.UIntPtr step), Expr.Const (value = Const.UIntPtr finish) -> ValueSome (Const.UIntPtr ((finish - start) / step + 1UL)) + | Expr.Const (value = Const.Int16 start), Expr.Const (value = Const.Int16 step), Expr.Const (value = Const.Int16 finish) -> ValueSome (Const.Int16 ((finish - start) / step + 1s)) + | Expr.Const (value = Const.UInt16 start), Expr.Const (value = Const.UInt16 step), Expr.Const (value = Const.UInt16 finish) -> ValueSome (Const.UInt16 ((finish - start) / step + 1us)) + | Expr.Const (value = Const.SByte start), Expr.Const (value = Const.SByte step), Expr.Const (value = Const.SByte finish) -> ValueSome (Const.SByte ((finish - start) / step + 1y)) + | Expr.Const (value = Const.Byte start), Expr.Const (value = Const.Byte step), Expr.Const (value = Const.Byte finish) -> ValueSome (Const.Byte ((finish - start) / step + 1uy)) + | Expr.Const (value = Const.Char start), Expr.Const (value = Const.Char step), Expr.Const (value = Const.Char finish) -> ValueSome (Const.Char (char (uint16 (finish - start) / uint16 step) + '\001')) | _ -> ValueNone let LowerComputedListOrArrayExpr tcVal (g: TcGlobals) amap overallExpr = // If ListCollector is in FSharp.Core then this optimization kicks in if g.ListCollector_tcr.CanDeref then + /// Make a call to invalidArg when step is 0. + let mkCallInvalidArgStepCannotBeZero m retTy = + mkCallInvalidArg + g + m + retTy + (Expr.Const (Const.String "step", Text.Range.range0, g.string_ty)) + (Expr.Const (Const.String "The step of a range cannot be zero.", Text.Range.range0, g.string_ty)) + /// Make an expression holding the count/length /// to initialize the collection with. - let mkCount start finish = - let diff = mkAsmExpr ([AI_sub], [], [finish; start], [g.int32_ty], Text.Range.range0) - mkAsmExpr ([AI_add], [], [diff; mkOne g Text.Range.range0], [g.int32_ty], Text.Range.range0) + let mkCount ty start step finish = + match step with + | Expr.Const (value = One) -> + let diff = mkAsmExpr ([AI_sub], [], [finish; start], [ty], Text.Range.range0) + mkAsmExpr ([AI_add], [], [diff; step], [ty], Text.Range.range0) + + | _notOne -> + let diff = mkAsmExpr ([AI_sub], [], [finish; start], [ty], Text.Range.range0) + let quotient = mkAsmExpr ([AI_div], [], [diff; step], [ty], Text.Range.range0) + mkAsmExpr ([AI_add], [], [quotient; step], [ty], Text.Range.range0) /// Make a lambda expression to pass into /// the Array.init/List.init call. - let mkInitializer start = - let v, e = mkCompGenLocal Text.Range.range0 "i" g.int32_ty - let body = mkAsmExpr ([AI_add], [], [start; e], [g.int32_ty], Text.Range.range0) - mkLambda Text.Range.range0 v (body, g.int32_ty) + let mkInitializer ty start step = + match step with + | Expr.Const (value = One) -> + let v, e = mkCompGenLocal Text.Range.range0 "i" g.int32_ty + let body = mkAsmExpr ([AI_add], [], [start; e], [ty], Text.Range.range0) + mkLambda Text.Range.range0 v (body, ty) + + | _notOne -> + let v, e = mkCompGenLocal Text.Range.range0 "i" g.int32_ty + let mulByStep = mkAsmExpr ([AI_mul], [], [e; step], [ty], Text.Range.range0) + let body = mkAsmExpr ([AI_add], [], [mulByStep; start], [ty], Text.Range.range0) + mkLambda Text.Range.range0 v (body, ty) /// Make an expression that initializes a list /// with the values from start through finish. - let mkListInit m start finish = - mkCond - DebugPointAtBinding.NoneAtInvisible - m - (mkListTy g g.int32_ty) - (mkILAsmClt g Text.Range.range0 finish start) - (mkNil g Text.Range.range0 g.int32_ty) - (mkCallListInit g Text.Range.range0 g.int32_ty (mkCount start finish) (mkInitializer start)) + let mkListInit m ty start step finish = + match step with + // [start..finish] → if finish < start then [] else List.init (finish - start + 1) ((+) start) + // [start..2..finish] → if finish < start then [] else List.init ((finish - start) / 2 + 1) ((*) 2 >> (+) start) + | Expr.Const (value = Positive) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + (mkListTy g ty) + (mkILAsmClt g Text.Range.range0 finish start) + (mkNil g Text.Range.range0 ty) + (mkCallListInit g Text.Range.range0 ty (mkCount ty start step finish) (mkInitializer ty start step)) + + // [start..-2..finish] → if start < finish then [] else List.init ((finish - start) / -2 + 1) ((*) -2 >> (+) start) + | Expr.Const (value = _negative) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + (mkListTy g ty) + (mkILAsmClt g Text.Range.range0 start finish) + (mkNil g Text.Range.range0 ty) + (mkCallListInit g Text.Range.range0 ty (mkCount ty start step finish) (mkInitializer ty start step)) + + // [start..step..finish] → let count = (finish - start) / step + 1 in if count = 0 then [] else List.init count ((*) step >> (+) start) + | _notConst -> + let listTy = mkListTy g ty + let count = mkCount ty start step finish + + let init = + mkCompGenLetIn Text.Range.range0 (nameof count) ty count (fun (_, count) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + listTy + (mkILAsmCeq g Text.Range.range0 count (mkZero g Text.Range.range0)) + (mkNil g Text.Range.range0 ty) + (mkCallListInit g Text.Range.range0 ty count (mkInitializer ty start step))) + + mkCond + DebugPointAtBinding.NoneAtInvisible + m + listTy + (mkILAsmCeq g Text.Range.range0 step (mkZero g Text.Range.range0)) + (mkCallInvalidArgStepCannotBeZero m listTy) + init /// Make an expression that initializes an array /// with the values from start through finish. - let mkArrayInit m start finish = - mkCond - DebugPointAtBinding.NoneAtInvisible - m - (mkArrayType g g.int32_ty) - (mkILAsmClt g Text.Range.range0 finish start) - (mkArray (g.int32_ty, [], Text.Range.range0)) - (mkCallArrayInit g Text.Range.range0 g.int32_ty (mkCount start finish) (mkInitializer start)) + let mkArrayInit m ty start step finish = + match step with + // [|start..finish|] → if finish < start then [||] else Array.init (finish - start + 1) ((+) start) + // [|start..2..finish|] → if finish < start then [||] else Array.init ((finish - start) / 2 + 1) ((*) 2 >> (+) start) + | Expr.Const (value = Positive) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + (mkArrayType g ty) + (mkILAsmClt g Text.Range.range0 finish start) + (mkArray (ty, [], Text.Range.range0)) + (mkCallArrayInit g Text.Range.range0 ty (mkCount ty start step finish) (mkInitializer ty start step)) + + // [|start..-2..finish|] → if start < finish then [||] else Array.init ((finish - start) / -2 + 1) ((*) -2 >> (+) start) + | Expr.Const (value = _negative) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + (mkArrayType g ty) + (mkILAsmClt g Text.Range.range0 start finish) + (mkArray (ty, [], Text.Range.range0)) + (mkCallArrayInit g Text.Range.range0 ty (mkCount ty start step finish) (mkInitializer ty start step)) + + // [|start..step..finish|] → let count = (finish - start) / step + 1 in if count = 0 then [||] else Array.init count ((*) step >> (+) start) + | _notConst -> + let arrayTy = mkArrayType g ty + let count = mkCount ty start step finish + + let init = + mkCompGenLetIn Text.Range.range0 (nameof count) ty count (fun (_, count) -> + mkCond + DebugPointAtBinding.NoneAtInvisible + m + arrayTy + (mkILAsmCeq g Text.Range.range0 count (mkZero g Text.Range.range0)) + (mkArray (ty, [], Text.Range.range0)) + (mkCallArrayInit g Text.Range.range0 ty count (mkInitializer ty start step))) + + mkCond + DebugPointAtBinding.NoneAtInvisible + m + arrayTy + (mkILAsmCeq g Text.Range.range0 step (mkZero g Text.Range.range0)) + (mkCallInvalidArgStepCannotBeZero m arrayTy) + init + + /// Bind start, step, and finish exprs to local variables if needed. + /// + /// E.g.: + /// + /// [start..finishExpr] → + /// let finish = finishExpr in + /// if finish < start then [] else List.init (finish - start + 1) ((+) start) + /// + /// [startExpr..finish] → + /// let start = startExpr in + /// if finish < start then [] else List.init (finish - start + 1) ((+) start) + let mkLetBindingsIfNeeded ty start step finish mkInitExpr = + match start, step, finish with + | (Expr.Const _ | Expr.Val _), (Expr.Const _ | Expr.Val _), (Expr.Const _ | Expr.Val _) -> + mkInitExpr ty start step finish + + | (Expr.Const _ | Expr.Val _), (Expr.Const _ | Expr.Val _), _ -> + mkCompGenLetIn Text.Range.range0 (nameof finish) ty finish (fun (_, finish) -> + mkInitExpr ty start step finish) + + | _, (Expr.Const _ | Expr.Val _), (Expr.Const _ | Expr.Val _) -> + mkCompGenLetIn Text.Range.range0 (nameof start) ty start (fun (_, start) -> + mkInitExpr ty start step finish) + + | (Expr.Const _ | Expr.Val _), _, (Expr.Const _ | Expr.Val _) -> + mkCompGenLetIn Text.Range.range0 (nameof step) ty step (fun (_, step) -> + mkInitExpr ty start step finish) + + | _, (Expr.Const _ | Expr.Val _), _ -> + mkCompGenLetIn Text.Range.range0 (nameof start) ty start (fun (_, start) -> + mkCompGenLetIn Text.Range.range0 (nameof finish) ty finish (fun (_, finish) -> + mkInitExpr ty start step finish)) + + | (Expr.Const _ | Expr.Val _), _, _ -> + mkCompGenLetIn Text.Range.range0 (nameof step) ty step (fun (_, step) -> + mkCompGenLetIn Text.Range.range0 (nameof finish) ty finish (fun (_, finish) -> + mkInitExpr ty start step finish)) + + | _, _, (Expr.Const _ | Expr.Val _) -> + mkCompGenLetIn Text.Range.range0 (nameof start) ty start (fun (_, start) -> + mkCompGenLetIn Text.Range.range0 (nameof step) ty step (fun (_, step) -> + mkInitExpr ty start step finish)) + + | _, _, _ -> + mkCompGenLetIn Text.Range.range0 (nameof start) ty start (fun (_, start) -> + mkCompGenLetIn Text.Range.range0 (nameof step) ty step (fun (_, step) -> + mkCompGenLetIn Text.Range.range0 (nameof finish) ty finish (fun (_, finish) -> + mkInitExpr ty start step finish))) match overallExpr with // […] | SeqToList g (OptionalCoerce (OptionalSeq g amap (overallSeqExpr, overallElemTy)), m) -> match overallSeqExpr with + // [start..0..finish] + | IntegralRange g (_, Expr.Const (value = Zero), _) -> + Some (mkCallInvalidArgStepCannotBeZero m (mkListTy g overallElemTy)) + // [5..1] → [] - | Int32Range g (Expr.Const (value = Const.Int32 start), Expr.Const (value = Const.Int32 finish)) when - finish < start - -> - Some (mkUnionCaseExpr (g.nil_ucref, [g.int32_ty], [], m)) + | IntegralRange g EmptyRange -> + Some (mkNil g m overallElemTy) // [1..5] → List.init 5 ((+) 5) - | Int32Range g (start & Expr.Const (value = Const.Int32 startVal), Expr.Const (value = Const.Int32 finishVal)) + | IntegralRange g ((start, step, _) & ConstCount count) -> - Some (mkCallListInit g Text.Range.range0 g.int32_ty (Expr.Const (Const.Int32 (finishVal - startVal + 1), Text.Range.range0, g.int32_ty)) (mkInitializer start)) + Some (mkCallListInit g Text.Range.range0 overallElemTy (Expr.Const (count, Text.Range.range0, overallElemTy)) (mkInitializer overallElemTy start step)) // [start..finish] → if finish < start then [] else List.init (finish - start + 1) ((+) start) - | Int32Range g (start & (Expr.Const _ | Expr.Val _), finish & (Expr.Const _ | Expr.Val _)) -> - Some (mkListInit m start finish) - - // [start..finishExpr] → - // let finish = finishExpr - // if finish < start then [] else List.init (finish - start + 1) ((+) start) - | Int32Range g (start & (Expr.Const _ | Expr.Val _), finish) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof finish) g.int32_ty finish (fun (_, finish) -> - mkListInit m start finish) - - Some expr - - // [startExpr..finish] → - // let start = startExpr - // if finish < start then [] else List.init (finish - start + 1) ((+) start) - | Int32Range g (start, finish & (Expr.Const _ | Expr.Val _)) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof start) g.int32_ty start (fun (_, start) -> - mkListInit m start finish) - - Some expr - - // [startExpr..finishExpr] → - // let start = startExpr - // let finish = finishExpr - // if finish < start then [] else List.init (finish - start + 1) ((+) start) - | Int32Range g (start, finish) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof start) g.int32_ty start (fun (_, start) -> - mkCompGenLetIn Text.Range.range0 (nameof finish) g.int32_ty finish (fun (_, finish) -> - mkListInit m start finish)) - - Some expr + // [start..step..finish] → let count = (finish - start) / step + 1 in if count = 0 then [] else List.init count ((*) step >> (+) start) + | IntegralRange g (start, step, finish) -> + Some (mkLetBindingsIfNeeded overallElemTy start step finish (mkListInit m)) // [(* Anything more complex. *)] | _ -> @@ -359,52 +579,23 @@ let LowerComputedListOrArrayExpr tcVal (g: TcGlobals) amap overallExpr = // [|…|] | SeqToArray g (OptionalCoerce (OptionalSeq g amap (overallSeqExpr, overallElemTy)), m) -> match overallSeqExpr with + // [|start..0..finish|] + | IntegralRange g (_, Expr.Const (value = Zero), _) -> + Some (mkCallInvalidArgStepCannotBeZero m (mkArrayType g overallElemTy)) + // [|5..1|] → [||] - | Int32Range g (Expr.Const (value = Const.Int32 start), Expr.Const (value = Const.Int32 finish)) when - finish < start - -> - Some (mkArray (g.int32_ty, [], m)) + | IntegralRange g EmptyRange -> + Some (mkArray (overallElemTy, [], m)) // [|1..5|] → Array.init 5 ((+) 5) - | Int32Range g (start & Expr.Const (value = Const.Int32 startVal), Expr.Const (value = Const.Int32 finishVal)) + | IntegralRange g ((start, step, _) & ConstCount count) -> - Some (mkCallArrayInit g Text.Range.range0 g.int32_ty (Expr.Const (Const.Int32 (finishVal - startVal + 1), Text.Range.range0, g.int32_ty)) (mkInitializer start)) + Some (mkCallArrayInit g Text.Range.range0 overallElemTy (Expr.Const (count, Text.Range.range0, overallElemTy)) (mkInitializer overallElemTy start step)) // [|start..finish|] → if finish < start then [||] else Array.init (finish - start + 1) ((+) start) - | Int32Range g (start & (Expr.Const _ | Expr.Val _), finish & (Expr.Const _ | Expr.Val _)) -> - Some (mkArrayInit m start finish) - - // [|start..finishExpr|] → - // let finish = finishExpr - // if finish < start then [||] else Array.init (finish - start + 1) ((+) start) - | Int32Range g (start & (Expr.Const _ | Expr.Val _), finish) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof finish) g.int32_ty finish (fun (_, finish) -> - mkArrayInit m start finish) - - Some expr - - // [|startExpr..finish|] → - // let start = startExpr - // if finish < start then [||] else Array.init (finish - start + 1) ((+) start) - | Int32Range g (start, finish & (Expr.Const _ | Expr.Val _)) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof start) g.int32_ty start (fun (_, start) -> - mkArrayInit m start finish) - - Some expr - - // [|startExpr..finishExpr|] → - // let start = startExpr - // let finish = finishExpr - // if finish < start then [||] else Array.init (finish - start + 1) ((+) start) - | Int32Range g (start, finish) -> - let expr = - mkCompGenLetIn Text.Range.range0 (nameof start) g.int32_ty start (fun (_, start) -> - mkCompGenLetIn Text.Range.range0 (nameof finish) g.int32_ty finish (fun (_, finish) -> - mkArrayInit m start finish)) - - Some expr + // [|start..step..finish|] → let count = (finish - start) / step + 1 in if count = 0 then [||] else Array.init count ((*) step >> (+) start) + | IntegralRange g (start, step, finish) -> + Some (mkLetBindingsIfNeeded overallElemTy start step finish (mkArrayInit m)) // [|(* Anything more complex. *)|] | _ -> diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index bf6661ddce6..b69effefabb 100644 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -809,6 +809,16 @@ type TcGlobals( let v_range_op_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "op_Range" , None , None , [vara], ([[varaTy];[varaTy]], mkSeqTy varaTy)) let v_range_step_op_info = makeIntrinsicValRef(fslib_MFOperators_nleref, "op_RangeStep" , None , None , [vara;varb], ([[varaTy];[varbTy];[varaTy]], mkSeqTy varaTy)) let v_range_int32_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeInt32" , None , None , [], ([[v_int_ty];[v_int_ty];[v_int_ty]], mkSeqTy v_int_ty)) + let v_range_int64_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeInt64" , None , None , [], ([[v_int64_ty];[v_int64_ty];[v_int64_ty]], mkSeqTy v_int64_ty)) + let v_range_uint64_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeUInt64" , None , None , [], ([[v_uint64_ty];[v_uint64_ty];[v_uint64_ty]], mkSeqTy v_uint64_ty)) + let v_range_uint32_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeUInt32" , None , None , [], ([[v_uint32_ty];[v_uint32_ty];[v_uint32_ty]], mkSeqTy v_uint32_ty)) + let v_range_nativeint_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeIntPtr" , None , None , [], ([[v_nativeint_ty];[v_nativeint_ty];[v_nativeint_ty]], mkSeqTy v_nativeint_ty)) + let v_range_unativeint_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeUIntPtr" , None , None , [], ([[v_unativeint_ty];[v_unativeint_ty];[v_unativeint_ty]], mkSeqTy v_unativeint_ty)) + let v_range_int16_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeInt16" , None , None , [], ([[v_int16_ty];[v_int16_ty];[v_int16_ty]], mkSeqTy v_int16_ty)) + let v_range_uint16_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeUInt16" , None , None , [], ([[v_uint16_ty];[v_uint16_ty];[v_uint16_ty]], mkSeqTy v_uint16_ty)) + let v_range_sbyte_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeSByte" , None , None , [], ([[v_sbyte_ty];[v_sbyte_ty];[v_sbyte_ty]], mkSeqTy v_sbyte_ty)) + let v_range_byte_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeByte" , None , None , [], ([[v_byte_ty];[v_byte_ty];[v_byte_ty]], mkSeqTy v_byte_ty)) + let v_range_char_op_info = makeIntrinsicValRef(fslib_MFOperatorIntrinsics_nleref, "RangeChar" , None , None , [], ([[v_char_ty];[v_char_ty];[v_char_ty]], mkSeqTy v_char_ty)) let v_array_length_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "length" , None , Some "Length" , [vara], ([[mkArrayType 1 varaTy]], v_int_ty)) let v_array_init_info = makeIntrinsicValRef(fslib_MFArrayModule_nleref, "init" , None , Some "Initialize", [vara], ([[v_int32_ty]; [v_int32_ty --> varaTy]], mkArrayType 1 varaTy)) @@ -821,7 +831,7 @@ type TcGlobals( let v_array3D_set_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "SetArray3D" , None , None , [vara], ([[mkArrayType 3 varaTy];[v_int_ty]; [v_int_ty]; [v_int_ty]; [varaTy]], v_unit_ty)) let v_array4D_set_info = makeIntrinsicValRef(fslib_MFIntrinsicFunctions_nleref, "SetArray4D" , None , None , [vara], ([[mkArrayType 4 varaTy];[v_int_ty]; [v_int_ty]; [v_int_ty]; [v_int_ty]; [varaTy]], v_unit_ty)) - let v_list_init_info = makeIntrinsicValRef(fslib_MFListModule_nleref, "init" , None , Some "Initialize", [vara], ([[v_int32_ty]; [v_int32_ty --> varaTy]], mkListTy varaTy)) + let v_list_init_info = makeIntrinsicValRef(fslib_MFListModule_nleref, "init" , None , Some "Initialize", [vara], ([[v_int32_ty]; [v_int32_ty --> varaTy]], mkListTy varaTy)) let v_option_toNullable_info = makeIntrinsicValRef(fslib_MFOptionModule_nleref, "toNullable" , None , Some "ToNullable" , [vara], ([[mkOptionTy varaTy]], mkNullableTy varaTy)) let v_option_defaultValue_info = makeIntrinsicValRef(fslib_MFOptionModule_nleref, "defaultValue" , None , Some "DefaultValue" , [vara], ([[varaTy]; [mkOptionTy varaTy]], varaTy)) @@ -1690,6 +1700,16 @@ type TcGlobals( member val range_op_vref = ValRefForIntrinsic v_range_op_info member val range_step_op_vref = ValRefForIntrinsic v_range_step_op_info member val range_int32_op_vref = ValRefForIntrinsic v_range_int32_op_info + member val range_int64_op_vref = ValRefForIntrinsic v_range_int64_op_info + member val range_uint64_op_vref = ValRefForIntrinsic v_range_uint64_op_info + member val range_uint32_op_vref = ValRefForIntrinsic v_range_uint32_op_info + member val range_nativeint_op_vref = ValRefForIntrinsic v_range_nativeint_op_info + member val range_unativeint_op_vref = ValRefForIntrinsic v_range_unativeint_op_info + member val range_int16_op_vref = ValRefForIntrinsic v_range_int16_op_info + member val range_uint16_op_vref = ValRefForIntrinsic v_range_uint16_op_info + member val range_sbyte_op_vref = ValRefForIntrinsic v_range_sbyte_op_info + member val range_byte_op_vref = ValRefForIntrinsic v_range_byte_op_info + member val range_char_op_vref = ValRefForIntrinsic v_range_char_op_info member val array_get_vref = ValRefForIntrinsic v_array_get_info member val array2D_get_vref = ValRefForIntrinsic v_array2D_get_info member val array3D_get_vref = ValRefForIntrinsic v_array3D_get_info diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 2e4f986efbc..ef67e6f03d3 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -7757,6 +7757,8 @@ let mkCallArray4DSet (g: TcGlobals) m ty e1 idx1 idx2 idx3 idx4 v = mkApps g (ty let mkCallListInit (g: TcGlobals) m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.list_init_info, [[ty]], [e1; e2], m) +let mkCallInvalidArg (g: TcGlobals) m ty e1 e2 = mkApps g (typedExprForIntrinsic g m g.invalid_arg_info, [[ty]], [e1; e2], m) + let mkCallHash (g: TcGlobals) m ty e1 = mkApps g (typedExprForIntrinsic g m g.hash_info, [[ty]], [ e1 ], m) let mkCallBox (g: TcGlobals) m ty e1 = mkApps g (typedExprForIntrinsic g m g.box_info, [[ty]], [ e1 ], m) diff --git a/src/Compiler/TypedTree/TypedTreeOps.fsi b/src/Compiler/TypedTree/TypedTreeOps.fsi index fd74ebf4b17..38b76c296e4 100755 --- a/src/Compiler/TypedTree/TypedTreeOps.fsi +++ b/src/Compiler/TypedTree/TypedTreeOps.fsi @@ -2035,6 +2035,8 @@ val mkCallArray4DSet: TcGlobals -> range -> TType -> Expr -> Expr -> Expr -> Exp val mkCallListInit: TcGlobals -> range -> TType -> Expr -> Expr -> Expr +val mkCallInvalidArg: TcGlobals -> range -> TType -> Expr -> Expr -> Expr + val mkCallHash: TcGlobals -> range -> TType -> Expr -> Expr val mkCallBox: TcGlobals -> range -> TType -> Expr -> Expr diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare08.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare08.fsx.il.bsl index 7c3b365ff57..4cf5d9ea271 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare08.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare08.fsx.il.bsl @@ -47,53 +47,123 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit t1@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/CompareMicroPerfAndCodeGenerationTests/t1@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint8 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/CompareMicroPerfAndCodeGenerationTests/t1@1::.ctor() + IL_0005: stsfld class assembly/CompareMicroPerfAndCodeGenerationTests/t1@1 assembly/CompareMicroPerfAndCodeGenerationTests/t1@1::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit t2@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/CompareMicroPerfAndCodeGenerationTests/t2@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint8 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/CompareMicroPerfAndCodeGenerationTests/t2@1::.ctor() + IL_0005: stsfld class assembly/CompareMicroPerfAndCodeGenerationTests/t2@1 assembly/CompareMicroPerfAndCodeGenerationTests/t2@1::@_instance + IL_000a: ret + } + + } + .method public static int32 f7() cil managed { - .maxstack 5 + .maxstack 4 .locals init (int32 V_0, uint8[] V_1, uint8[] V_2, int32 V_3) IL_0000: ldc.i4.1 IL_0001: stloc.0 - IL_0002: ldc.i4.0 - IL_0003: ldc.i4.1 - IL_0004: ldc.i4.s 100 - IL_0006: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeByte(uint8, - uint8, - uint8) - IL_000b: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::CreateSequence(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0010: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.SeqModule::ToArray(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0015: stloc.1 - IL_0016: ldc.i4.0 - IL_0017: ldc.i4.1 - IL_0018: ldc.i4.s 100 - IL_001a: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeByte(uint8, - uint8, - uint8) - IL_001f: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::CreateSequence(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0024: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.SeqModule::ToArray(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0029: stloc.2 - IL_002a: ldc.i4.0 + IL_0002: ldc.i4.s 101 + IL_0004: ldsfld class assembly/CompareMicroPerfAndCodeGenerationTests/t1@1 assembly/CompareMicroPerfAndCodeGenerationTests/t1@1::@_instance + IL_0009: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_000e: stloc.1 + IL_000f: ldc.i4.s 101 + IL_0011: ldsfld class assembly/CompareMicroPerfAndCodeGenerationTests/t2@1 assembly/CompareMicroPerfAndCodeGenerationTests/t2@1::@_instance + IL_0016: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001b: stloc.2 + IL_001c: ldc.i4.0 + IL_001d: stloc.3 + IL_001e: br.s IL_002c + + IL_0020: ldloc.1 + IL_0021: ldloc.2 + IL_0022: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericComparisonIntrinsic(!!0, + !!0) + IL_0027: stloc.0 + IL_0028: ldloc.3 + IL_0029: ldc.i4.1 + IL_002a: add IL_002b: stloc.3 - IL_002c: br.s IL_003a + IL_002c: ldloc.3 + IL_002d: ldc.i4 0x989681 + IL_0032: blt.s IL_0020 - IL_002e: ldloc.1 - IL_002f: ldloc.2 - IL_0030: call int32 [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericComparisonIntrinsic(!!0, - !!0) - IL_0035: stloc.0 - IL_0036: ldloc.3 - IL_0037: ldc.i4.1 - IL_0038: add - IL_0039: stloc.3 - IL_003a: ldloc.3 - IL_003b: ldc.i4 0x989681 - IL_0040: blt.s IL_002e - - IL_0042: ldloc.0 - IL_0043: ret + IL_0034: ldloc.0 + IL_0035: ret } } diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals07.fsx.il.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals07.fsx.il.bsl index a175818aeb3..3519fd8a3d7 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals07.fsx.il.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals07.fsx.il.bsl @@ -47,53 +47,123 @@ extends [runtime]System.Object { .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit t1@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint8 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1::.ctor() + IL_0005: stsfld class assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1 assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1::@_instance + IL_000a: ret + } + + } + + .class auto ansi serializable sealed nested assembly beforefieldinit t2@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint8 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1::.ctor() + IL_0005: stsfld class assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1 assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1::@_instance + IL_000a: ret + } + + } + .method public static bool f7() cil managed { - .maxstack 5 + .maxstack 4 .locals init (bool V_0, uint8[] V_1, uint8[] V_2, int32 V_3) IL_0000: ldc.i4.0 IL_0001: stloc.0 - IL_0002: ldc.i4.0 - IL_0003: ldc.i4.1 - IL_0004: ldc.i4.s 100 - IL_0006: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeByte(uint8, - uint8, - uint8) - IL_000b: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::CreateSequence(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0010: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.SeqModule::ToArray(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0015: stloc.1 - IL_0016: ldc.i4.0 - IL_0017: ldc.i4.1 - IL_0018: ldc.i4.s 100 - IL_001a: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators/OperatorIntrinsics::RangeByte(uint8, - uint8, - uint8) - IL_001f: call class [runtime]System.Collections.Generic.IEnumerable`1 [FSharp.Core]Microsoft.FSharp.Core.Operators::CreateSequence(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0024: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.SeqModule::ToArray(class [runtime]System.Collections.Generic.IEnumerable`1) - IL_0029: stloc.2 - IL_002a: ldc.i4.0 + IL_0002: ldc.i4.s 101 + IL_0004: ldsfld class assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1 assembly/EqualsMicroPerfAndCodeGenerationTests/t1@1::@_instance + IL_0009: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_000e: stloc.1 + IL_000f: ldc.i4.s 101 + IL_0011: ldsfld class assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1 assembly/EqualsMicroPerfAndCodeGenerationTests/t2@1::@_instance + IL_0016: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001b: stloc.2 + IL_001c: ldc.i4.0 + IL_001d: stloc.3 + IL_001e: br.s IL_002c + + IL_0020: ldloc.1 + IL_0021: ldloc.2 + IL_0022: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, + !!0) + IL_0027: stloc.0 + IL_0028: ldloc.3 + IL_0029: ldc.i4.1 + IL_002a: add IL_002b: stloc.3 - IL_002c: br.s IL_003a + IL_002c: ldloc.3 + IL_002d: ldc.i4 0x989681 + IL_0032: blt.s IL_0020 - IL_002e: ldloc.1 - IL_002f: ldloc.2 - IL_0030: call bool [FSharp.Core]Microsoft.FSharp.Core.LanguagePrimitives/HashCompare::GenericEqualityIntrinsic(!!0, - !!0) - IL_0035: stloc.0 - IL_0036: ldloc.3 - IL_0037: ldc.i4.1 - IL_0038: add - IL_0039: stloc.3 - IL_003a: ldloc.3 - IL_003b: ldc.i4 0x989681 - IL_0040: blt.s IL_002e - - IL_0042: ldloc.0 - IL_0043: ret + IL_0034: ldloc.0 + IL_0035: ret } } diff --git a/tests/fsharp/Compiler/Language/ComputedCollectionLoweringTests.fs b/tests/fsharp/Compiler/Language/ComputedCollectionLoweringTests.fs deleted file mode 100644 index 0aa0d2639df..00000000000 --- a/tests/fsharp/Compiler/Language/ComputedCollectionLoweringTests.fs +++ /dev/null @@ -1,888 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -namespace FSharp.Compiler.UnitTests - -open NUnit.Framework -open FSharp.Test - -[] -module ComputedCollectionLoweringTests = - module Array = - [] - let ``Lone RangeInt32 with const args when start > finish lowers to empty array`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test () = [|10..1|] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - 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[] test() cil managed - { - - .maxstack 8 - IL_0000: call !!0[] [runtime]System.Array::Empty() - IL_0005: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with const args lowers to call to init`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test () = [|1..257|] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class Test/test@1 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void Test/test@1::.ctor() - IL_0005: stsfld class Test/test@1 Test/test@1::@_instance - IL_000a: ret - } - - } - - .method public static int32[] test() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4 0x101 - IL_0005: ldsfld class Test/test@1 Test/test@1::@_instance - IL_000a: tail. - IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_0011: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with dynamic args lowers to call to init`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test start finish = [|start..finish|] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field public int32 start - .method assembly specialname rtspecialname - instance void .ctor(int32 start) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 Test/test@1::start - IL_000d: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld int32 Test/test@1::start - IL_0006: ldarg.1 - IL_0007: add - IL_0008: ret - } - - } - - .method public static int32[] test(int32 start, - int32 finish) 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 8 - IL_0000: ldarg.1 - IL_0001: ldarg.0 - IL_0002: bge.s IL_000a - - IL_0004: call !!0[] [runtime]System.Array::Empty() - IL_0009: ret - - IL_000a: ldarg.1 - IL_000b: ldarg.0 - IL_000c: sub - IL_000d: ldc.i4.1 - IL_000e: add - IL_000f: ldarg.0 - IL_0010: newobj instance void Test/test@1::.ctor(int32) - IL_0015: tail. - IL_0017: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_001c: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let a () = (Array.zeroCreate 10).Length - let b () = (Array.zeroCreate 20).Length - - let test start finish = [|a ()..b ()|] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field public int32 start - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method assembly specialname rtspecialname - instance void .ctor(int32 start) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 Test/test@1::start - IL_000d: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld int32 Test/test@1::start - IL_0006: ldarg.1 - IL_0007: add - IL_0008: ret - } - - } - - .method public static int32 a() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.s 10 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: ret - } - - .method public static int32 b() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.s 20 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: ret - } - - .method public static int32[] test(!!a start, - !!b finish) 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 4 - .locals init (int32 V_0, - int32 V_1) - IL_0000: ldc.i4.s 10 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: stloc.0 - IL_000a: ldc.i4.s 20 - IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0011: ldlen - IL_0012: conv.i4 - IL_0013: stloc.1 - IL_0014: ldloc.1 - IL_0015: ldloc.0 - IL_0016: bge.s IL_001e - - IL_0018: call !!0[] [runtime]System.Array::Empty() - IL_001d: ret - - IL_001e: ldloc.1 - IL_001f: ldloc.0 - IL_0020: sub - IL_0021: ldc.i4.1 - IL_0022: add - IL_0023: ldloc.0 - IL_0024: newobj instance void Test/test@1::.ctor(int32) - IL_0029: tail. - IL_002b: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_0030: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - module List = - [] - let ``Lone RangeInt32 with const args when start > finish lowers to empty list`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test () = [10..1] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - 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 - test() cil managed - { - - .maxstack 8 - IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() - IL_0005: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with const args lowers to call to init`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test () = [1..101] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field static assembly initonly class Test/test@1 @_instance - .method assembly specialname rtspecialname - instance void .ctor() cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.1 - IL_0001: ldarg.1 - IL_0002: add - IL_0003: ret - } - - .method private specialname rtspecialname static - void .cctor() cil managed - { - - .maxstack 10 - IL_0000: newobj instance void Test/test@1::.ctor() - IL_0005: stsfld class Test/test@1 Test/test@1::@_instance - IL_000a: ret - } - - } - - .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 - test() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.s 101 - IL_0002: ldsfld class Test/test@1 Test/test@1::@_instance - IL_0007: tail. - IL_0009: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_000e: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with dynamic args lowers to call to init``() = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let test start finish = [start..finish] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field public int32 start - .method assembly specialname rtspecialname - instance void .ctor(int32 start) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 Test/test@1::start - IL_000d: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld int32 Test/test@1::start - IL_0006: ldarg.1 - IL_0007: add - IL_0008: ret - } - - } - - .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 - test(int32 start, - int32 finish) 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 8 - IL_0000: ldarg.1 - IL_0001: ldarg.0 - IL_0002: bge.s IL_000a - - IL_0004: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() - IL_0009: ret - - IL_000a: ldarg.1 - IL_000b: ldarg.0 - IL_000c: sub - IL_000d: ldc.i4.1 - IL_000e: add - IL_000f: ldarg.0 - IL_0010: newobj instance void Test/test@1::.ctor(int32) - IL_0015: tail. - IL_0017: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_001c: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) - - [] - let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = - CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], - """ - module Test - - let a () = (Array.zeroCreate 10).Length - let b () = (Array.zeroCreate 20).Length - - let test start finish = [a ()..b ()] - """, - (fun verifier -> verifier.VerifyIL [ - """ - .assembly extern runtime { } - .assembly extern FSharp.Core { } - .assembly assembly - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, - int32, - int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) - .hash algorithm 0x00008004 - .ver 0:0:0:0 - } - .mresource public FSharpSignatureData.assembly - { - - - } - .mresource public FSharpOptimizationData.assembly - { - - - } - .module assembly.dll - - .imagebase {value} - .file alignment 0x00000200 - .stackreserve 0x00100000 - .subsystem 0x0003 - .corflags 0x00000001 - - - - - - .class public abstract auto ansi sealed Test - extends [runtime]System.Object - { - .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) - .class auto ansi serializable sealed nested assembly beforefieldinit test@1 - extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 - { - .field public int32 start - .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - .method assembly specialname rtspecialname - instance void .ctor(int32 start) cil managed - { - .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() - IL_0006: ldarg.0 - IL_0007: ldarg.1 - IL_0008: stfld int32 Test/test@1::start - IL_000d: ret - } - - .method public strict virtual instance int32 - Invoke(int32 i) cil managed - { - - .maxstack 8 - IL_0000: ldarg.0 - IL_0001: ldfld int32 Test/test@1::start - IL_0006: ldarg.1 - IL_0007: add - IL_0008: ret - } - - } - - .method public static int32 a() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.s 10 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: ret - } - - .method public static int32 b() cil managed - { - - .maxstack 8 - IL_0000: ldc.i4.s 20 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: ret - } - - .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 - test(!!a start, - !!b finish) 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 4 - .locals init (int32 V_0, - int32 V_1) - IL_0000: ldc.i4.s 10 - IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0007: ldlen - IL_0008: conv.i4 - IL_0009: stloc.0 - IL_000a: ldc.i4.s 20 - IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) - IL_0011: ldlen - IL_0012: conv.i4 - IL_0013: stloc.1 - IL_0014: ldloc.1 - IL_0015: ldloc.0 - IL_0016: bge.s IL_001e - - IL_0018: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() - IL_001d: ret - - IL_001e: ldloc.1 - IL_001f: ldloc.0 - IL_0020: sub - IL_0021: ldc.i4.1 - IL_0022: add - IL_0023: ldloc.0 - IL_0024: newobj instance void Test/test@1::.ctor(int32) - IL_0029: tail. - IL_002b: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, - class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) - IL_0030: ret - } - - } - - .class private abstract auto ansi sealed ''.$Test - extends [runtime]System.Object - { - } - """ - ])) diff --git a/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int32.fs b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int32.fs new file mode 100644 index 00000000000..bf5c06bece8 --- /dev/null +++ b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int32.fs @@ -0,0 +1,2048 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests.ComputedCollectionRangeLoweringTests + +open NUnit.Framework +open FSharp.Test + +[] +module Int32 = + module Array = + /// [|start..finish|] + module Range = + [] + let ``Lone RangeInt32 with const args when start > finish lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|10..1|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1..257|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static int32[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x101 + IL_0005: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000a: tail. + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test start finish = [|start..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .method assembly specialname rtspecialname + instance void .ctor(int32 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int32[] test(int32 start, + int32 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call !!0[] [runtime]System.Array::Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: add + IL_000f: ldarg.0 + IL_0010: newobj instance void Test/test@1::.ctor(int32) + IL_0015: tail. + IL_0017: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001c: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).Length + let b () = (Array.zeroCreate 20).Length + + let test () = [|a ()..b ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int32 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32[] test() cil managed + { + + .maxstack 4 + .locals init (int32 V_0, + int32 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: stloc.0 + IL_000a: ldc.i4.s 20 + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0011: ldlen + IL_0012: conv.i4 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: ldloc.0 + IL_0016: bge.s IL_001e + + IL_0018: call !!0[] [runtime]System.Array::Empty() + IL_001d: ret + + IL_001e: ldloc.1 + IL_001f: ldloc.0 + IL_0020: sub + IL_0021: ldc.i4.1 + IL_0022: add + IL_0023: ldloc.0 + IL_0024: newobj instance void Test/test@1::.ctor(int32) + IL_0029: tail. + IL_002b: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0030: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [|start..step..finish|] + module RangeStep = + [] + let ``Lone RangeInt32 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1..0..5|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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[] test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1..-1..5|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1..2..257|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: mul + IL_0003: ldc.i4.1 + IL_0004: add + IL_0005: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static int32[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000a: tail. + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test start step finish = [|start..step..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .field public int32 step + .method assembly specialname rtspecialname + instance void .ctor(int32 start, + int32 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int32 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int32 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int32 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int32[] test(int32 start, + int32 step, + int32 finish) 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 (int32 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call !!0[] [runtime]System.Array::Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(int32, + int32) + IL_002e: tail. + IL_0030: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).Length + let b () = (Array.zeroCreate 20).Length + let c () = (Array.zeroCreate 300).Length + + let test () = [|a () .. b () .. c ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 start, + int32 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int32 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int32 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int32 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int32 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: ldlen + IL_000b: conv.i4 + IL_000c: ret + } + + .method public static int32[] test() cil managed + { + + .maxstack 5 + .locals init (int32 V_0, + int32 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: stloc.0 + IL_000a: ldc.i4.s 20 + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0011: ldlen + IL_0012: conv.i4 + IL_0013: stloc.1 + IL_0014: ldc.i4 0x12c + IL_0019: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_001e: ldlen + IL_001f: conv.i4 + IL_0020: stloc.2 + IL_0021: ldloc.1 + IL_0022: brtrue.s IL_0036 + + IL_0024: ldstr "step" + IL_0029: ldstr "The step of a range cannot be zero." + IL_002e: tail. + IL_0030: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0035: ret + + IL_0036: ldloc.2 + IL_0037: ldloc.0 + IL_0038: sub + IL_0039: ldloc.1 + IL_003a: div + IL_003b: ldloc.1 + IL_003c: add + IL_003d: stloc.3 + IL_003e: ldloc.3 + IL_003f: brtrue.s IL_0047 + + IL_0041: call !!0[] [runtime]System.Array::Empty() + IL_0046: ret + + IL_0047: ldloc.3 + IL_0048: ldloc.0 + IL_0049: ldloc.1 + IL_004a: newobj instance void Test/test@1::.ctor(int32, + int32) + IL_004f: tail. + IL_0051: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0056: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + module List = + /// [start..finish] + module Range = + [] + let ``Lone RangeInt32 with const args when start > finish lowers to empty list`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [10..1] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [1..101] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: ldarg.1 + IL_0002: add + IL_0003: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 101 + IL_0002: ldsfld class Test/test@1 Test/test@1::@_instance + IL_0007: tail. + IL_0009: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_000e: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args lowers to call to init``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test start finish = [start..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .method assembly specialname rtspecialname + instance void .ctor(int32 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(int32 start, + int32 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: add + IL_000f: ldarg.0 + IL_0010: newobj instance void Test/test@1::.ctor(int32) + IL_0015: tail. + IL_0017: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001c: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).Length + let b () = (Array.zeroCreate 20).Length + + let test () = [a ()..b ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int32 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int32 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 4 + .locals init (int32 V_0, + int32 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: stloc.0 + IL_000a: ldc.i4.s 20 + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0011: ldlen + IL_0012: conv.i4 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: ldloc.0 + IL_0016: bge.s IL_001e + + IL_0018: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_001d: ret + + IL_001e: ldloc.1 + IL_001f: ldloc.0 + IL_0020: sub + IL_0021: ldc.i4.1 + IL_0022: add + IL_0023: ldloc.0 + IL_0024: newobj instance void Test/test@1::.ctor(int32) + IL_0029: tail. + IL_002b: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0030: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [start..step..finish] + module RangeStep = + [] + let ``Lone RangeInt32 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1..0..5] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1..-1..5] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1..2..257] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: mul + IL_0003: ldc.i4.1 + IL_0004: add + IL_0005: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000a: tail. + IL_000c: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test start step finish = [start..step..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .field public int32 step + .method assembly specialname rtspecialname + instance void .ctor(int32 start, + int32 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int32 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int32 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int32 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(int32 start, + int32 step, + int32 finish) 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 (int32 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(int32, + int32) + IL_002e: tail. + IL_0030: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt32 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let a () = (Array.zeroCreate 10).Length + let b () = (Array.zeroCreate 20).Length + let c () = (Array.zeroCreate 300).Length + + let test () = [a () .. b () .. c ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int32 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public int32 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int32 start, + int32 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int32 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int32 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int32 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int32 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int32 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int32 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: ret + } + + .method public static int32 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: ldlen + IL_000b: conv.i4 + IL_000c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 5 + .locals init (int32 V_0, + int32 V_1, + int32 V_2, + int32 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: stloc.0 + IL_000a: ldc.i4.s 20 + IL_000c: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0011: ldlen + IL_0012: conv.i4 + IL_0013: stloc.1 + IL_0014: ldc.i4 0x12c + IL_0019: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_001e: ldlen + IL_001f: conv.i4 + IL_0020: stloc.2 + IL_0021: ldloc.1 + IL_0022: brtrue.s IL_0036 + + IL_0024: ldstr "step" + IL_0029: ldstr "The step of a range cannot be zero." + IL_002e: tail. + IL_0030: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0035: ret + + IL_0036: ldloc.2 + IL_0037: ldloc.0 + IL_0038: sub + IL_0039: ldloc.1 + IL_003a: div + IL_003b: ldloc.1 + IL_003c: add + IL_003d: stloc.3 + IL_003e: ldloc.3 + IL_003f: brtrue.s IL_0047 + + IL_0041: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0046: ret + + IL_0047: ldloc.3 + IL_0048: ldloc.0 + IL_0049: ldloc.1 + IL_004a: newobj instance void Test/test@1::.ctor(int32, + int32) + IL_004f: tail. + IL_0051: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0056: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + diff --git a/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int64.fs b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int64.fs new file mode 100644 index 00000000000..7782158f7f0 --- /dev/null +++ b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.Int64.fs @@ -0,0 +1,2042 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests.ComputedCollectionRangeLoweringTests + +open NUnit.Framework +open FSharp.Test + +[] +module Int64 = + module Array = + /// [|start..finish|] + module Range = + [] + let ``Lone RangeInt64 with const args when start > finish lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|10L..1L|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 int64[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1L..257L|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: conv.i8 + IL_0002: ldarg.1 + IL_0003: add + IL_0004: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static int64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x101 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : int64) (finish : int64) = [|start..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .method assembly specialname rtspecialname + instance void .ctor(int64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int64[] test(int64 start, + int64 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call !!0[] [runtime]System.Array::Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: conv.i8 + IL_000f: add + IL_0010: ldarg.0 + IL_0011: newobj instance void Test/test@1::.ctor(int64) + IL_0016: tail. + IL_0018: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001d: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).LongLength + let b () = (Array.zeroCreate 20).LongLength + + let test () = [|a ()..b ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64[] test() cil managed + { + + .maxstack 4 + .locals init (int64 V_0, + int64 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: stloc.0 + IL_000d: ldc.i4.s 20 + IL_000f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0014: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0019: stloc.1 + IL_001a: ldloc.1 + IL_001b: ldloc.0 + IL_001c: bge.s IL_0024 + + IL_001e: call !!0[] [runtime]System.Array::Empty() + IL_0023: ret + + IL_0024: ldloc.1 + IL_0025: ldloc.0 + IL_0026: sub + IL_0027: ldc.i4.1 + IL_0028: conv.i8 + IL_0029: add + IL_002a: ldloc.0 + IL_002b: newobj instance void Test/test@1::.ctor(int64) + IL_0030: tail. + IL_0032: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0037: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [|start..step..finish|] + module RangeStep = + [] + let ``Lone RangeInt64 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1L..0L..5L|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 int64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1L.. -1L..5L|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 int64[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1L..2L..257L|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: conv.i8 + IL_0003: mul + IL_0004: ldc.i4.1 + IL_0005: conv.i8 + IL_0006: add + IL_0007: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static int64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : int64) (step : int64) (finish : int64) = [|start..step..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .field public int64 step + .method assembly specialname rtspecialname + instance void .ctor(int64 start, + int64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int64[] test(int64 start, + int64 step, + int64 finish) 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 (int64 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call !!0[] [runtime]System.Array::Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(int64, + int64) + IL_002e: tail. + IL_0030: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).LongLength + let b () = (Array.zeroCreate 20).LongLength + let c () = (Array.zeroCreate 300).LongLength + + let test () = [|a () .. b () .. c ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public int64 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int64 start, + int64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000f: ret + } + + .method public static int64[] test() cil managed + { + + .maxstack 5 + .locals init (int64 V_0, + int64 V_1, + int64 V_2, + int64 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: stloc.0 + IL_000d: ldc.i4.s 20 + IL_000f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0014: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0019: stloc.1 + IL_001a: ldc.i4 0x12c + IL_001f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0024: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0029: stloc.2 + IL_002a: ldloc.1 + IL_002b: brtrue.s IL_003f + + IL_002d: ldstr "step" + IL_0032: ldstr "The step of a range cannot be zero." + IL_0037: tail. + IL_0039: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_003e: ret + + IL_003f: ldloc.2 + IL_0040: ldloc.0 + IL_0041: sub + IL_0042: ldloc.1 + IL_0043: div + IL_0044: ldloc.1 + IL_0045: add + IL_0046: stloc.3 + IL_0047: ldloc.3 + IL_0048: brtrue.s IL_0050 + + IL_004a: call !!0[] [runtime]System.Array::Empty() + IL_004f: ret + + IL_0050: ldloc.3 + IL_0051: ldloc.0 + IL_0052: ldloc.1 + IL_0053: newobj instance void Test/test@1::.ctor(int64, + int64) + IL_0058: tail. + IL_005a: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_005f: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + module List = + /// [start..finish] + module Range = + [] + let ``Lone RangeInt64 with const args when start > finish lowers to empty list`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [10L..1L] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [1L..101L] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: conv.i8 + IL_0002: ldarg.1 + IL_0003: add + IL_0004: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 101 + IL_0002: conv.i8 + IL_0003: ldsfld class Test/test@1 Test/test@1::@_instance + IL_0008: tail. + IL_000a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_000f: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args lowers to call to init``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : int64) (finish : int64) = [start..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .method assembly specialname rtspecialname + instance void .ctor(int64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(int64 start, + int64 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: conv.i8 + IL_000f: add + IL_0010: ldarg.0 + IL_0011: newobj instance void Test/test@1::.ctor(int64) + IL_0016: tail. + IL_0018: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001d: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = (Array.zeroCreate 10).LongLength + let b () = (Array.zeroCreate 20).LongLength + + let test () = [a ()..b ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld int64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static int64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 4 + .locals init (int64 V_0, + int64 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: stloc.0 + IL_000d: ldc.i4.s 20 + IL_000f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0014: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0019: stloc.1 + IL_001a: ldloc.1 + IL_001b: ldloc.0 + IL_001c: bge.s IL_0024 + + IL_001e: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0023: ret + + IL_0024: ldloc.1 + IL_0025: ldloc.0 + IL_0026: sub + IL_0027: ldc.i4.1 + IL_0028: conv.i8 + IL_0029: add + IL_002a: ldloc.0 + IL_002b: newobj instance void Test/test@1::.ctor(int64) + IL_0030: tail. + IL_0032: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0037: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [start..step..finish] + module RangeStep = + [] + let ``Lone RangeInt64 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1L..0L..5L] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1L.. -1L..5L] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1L..2L..257L] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: conv.i8 + IL_0003: mul + IL_0004: ldc.i4.1 + IL_0005: conv.i8 + IL_0006: add + IL_0007: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test (start : int64) (step : int64) (finish : int64) = [start..step..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .field public int64 step + .method assembly specialname rtspecialname + instance void .ctor(int64 start, + int64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(int64 start, + int64 step, + int64 finish) 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 (int64 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(int64, + int64) + IL_002e: tail. + IL_0030: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let a () = (Array.zeroCreate 10).LongLength + let b () = (Array.zeroCreate 20).LongLength + let c () = (Array.zeroCreate 300).LongLength + + let test () = [a () .. b () .. c ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public int64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public int64 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(int64 start, + int64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld int64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld int64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance int64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld int64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld int64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static int64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: ret + } + + .method public static int64 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000f: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 5 + .locals init (int64 V_0, + int64 V_1, + int64 V_2, + int64 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_000c: stloc.0 + IL_000d: ldc.i4.s 20 + IL_000f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0014: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0019: stloc.1 + IL_001a: ldc.i4 0x12c + IL_001f: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0024: callvirt instance int64 [runtime]System.Array::get_LongLength() + IL_0029: stloc.2 + IL_002a: ldloc.1 + IL_002b: brtrue.s IL_003f + + IL_002d: ldstr "step" + IL_0032: ldstr "The step of a range cannot be zero." + IL_0037: tail. + IL_0039: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_003e: ret + + IL_003f: ldloc.2 + IL_0040: ldloc.0 + IL_0041: sub + IL_0042: ldloc.1 + IL_0043: div + IL_0044: ldloc.1 + IL_0045: add + IL_0046: stloc.3 + IL_0047: ldloc.3 + IL_0048: brtrue.s IL_0050 + + IL_004a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_004f: ret + + IL_0050: ldloc.3 + IL_0051: ldloc.0 + IL_0052: ldloc.1 + IL_0053: newobj instance void Test/test@1::.ctor(int64, + int64) + IL_0058: tail. + IL_005a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_005f: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + diff --git a/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.UInt64.fs b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.UInt64.fs new file mode 100644 index 00000000000..b005383f031 --- /dev/null +++ b/tests/fsharp/Compiler/Language/ComputedCollectionRangeLoweringTests.UInt64.fs @@ -0,0 +1,2082 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests.ComputedCollectionRangeLoweringTests + +open NUnit.Framework +open FSharp.Test + +[] +module UInt64 = + module Array = + /// [|start..finish|] + module Range = + [] + let ``Lone RangeUInt64 with const args when start > finish lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|10UL..1UL|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 uint64[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1UL..257UL|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: conv.i8 + IL_0002: ldarg.1 + IL_0003: add + IL_0004: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static uint64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x101 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : uint64) (finish : uint64) = [|start..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .method assembly specialname rtspecialname + instance void .ctor(uint64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld uint64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static uint64[] test(uint64 start, + uint64 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call !!0[] [runtime]System.Array::Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: conv.i8 + IL_000f: add + IL_0010: ldarg.0 + IL_0011: newobj instance void Test/test@1::.ctor(uint64) + IL_0016: tail. + IL_0018: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001d: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = uint64 (Array.zeroCreate 10).Length + let b () = uint64 (Array.zeroCreate 20).Length + + let test () = [|a ()..b ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(uint64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld uint64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static uint64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64[] test() cil managed + { + + .maxstack 4 + .locals init (uint64 V_0, + uint64 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: stloc.0 + IL_000b: ldc.i4.s 20 + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0012: ldlen + IL_0013: conv.i4 + IL_0014: conv.i8 + IL_0015: stloc.1 + IL_0016: ldloc.1 + IL_0017: ldloc.0 + IL_0018: bge.s IL_0020 + + IL_001a: call !!0[] [runtime]System.Array::Empty() + IL_001f: ret + + IL_0020: ldloc.1 + IL_0021: ldloc.0 + IL_0022: sub + IL_0023: ldc.i4.1 + IL_0024: conv.i8 + IL_0025: add + IL_0026: ldloc.0 + IL_0027: newobj instance void Test/test@1::.ctor(uint64) + IL_002c: tail. + IL_002e: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0033: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [|start..step..finish|] + module RangeStep = + [] + let ``Lone RangeUInt64 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1UL..0UL..5UL|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 uint64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|5UL..1UL..1UL|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 uint64[] test() cil managed + { + + .maxstack 8 + IL_0000: call !!0[] [runtime]System.Array::Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [|1UL..2UL..257UL|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: conv.i8 + IL_0003: mul + IL_0004: ldc.i4.1 + IL_0005: conv.i8 + IL_0006: add + IL_0007: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static uint64[] test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : uint64) (step : uint64) (finish : uint64) = [|start..step..finish|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .field public uint64 step + .method assembly specialname rtspecialname + instance void .ctor(uint64 start, + uint64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld uint64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld uint64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld uint64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static uint64[] test(uint64 start, + uint64 step, + uint64 finish) 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 (uint64 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call !!0[] [runtime]System.Array::Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(uint64, + uint64) + IL_002e: tail. + IL_0030: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = uint64 (Array.zeroCreate 10).Length + let b () = uint64 (Array.zeroCreate 20).Length + let c () = uint64 (Array.zeroCreate 300).Length + + let test () = [|a () .. b () .. c ()|] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public uint64 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(uint64 start, + uint64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld uint64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld uint64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld uint64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static uint64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: ldlen + IL_000b: conv.i4 + IL_000c: conv.i8 + IL_000d: ret + } + + .method public static uint64[] test() cil managed + { + + .maxstack 5 + .locals init (uint64 V_0, + uint64 V_1, + uint64 V_2, + uint64 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: stloc.0 + IL_000b: ldc.i4.s 20 + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0012: ldlen + IL_0013: conv.i4 + IL_0014: conv.i8 + IL_0015: stloc.1 + IL_0016: ldc.i4 0x12c + IL_001b: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0020: ldlen + IL_0021: conv.i4 + IL_0022: conv.i8 + IL_0023: stloc.2 + IL_0024: ldloc.1 + IL_0025: brtrue.s IL_0039 + + IL_0027: ldstr "step" + IL_002c: ldstr "The step of a range cannot be zero." + IL_0031: tail. + IL_0033: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg(string, + string) + IL_0038: ret + + IL_0039: ldloc.2 + IL_003a: ldloc.0 + IL_003b: sub + IL_003c: ldloc.1 + IL_003d: div + IL_003e: ldloc.1 + IL_003f: add + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: brtrue.s IL_004a + + IL_0044: call !!0[] [runtime]System.Array::Empty() + IL_0049: ret + + IL_004a: ldloc.3 + IL_004b: ldloc.0 + IL_004c: ldloc.1 + IL_004d: newobj instance void Test/test@1::.ctor(uint64, + uint64) + IL_0052: tail. + IL_0054: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0059: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + module List = + /// [start..finish] + module Range = + [] + let ``Lone RangeUInt64 with const args when start > finish lowers to empty list`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [10UL..1UL] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test () = [1UL..101UL] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.1 + IL_0001: conv.i8 + IL_0002: ldarg.1 + IL_0003: add + IL_0004: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 101 + IL_0002: conv.i8 + IL_0003: ldsfld class Test/test@1 Test/test@1::@_instance + IL_0008: tail. + IL_000a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_000f: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args lowers to call to init``() = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let test (start : uint64) (finish : uint64) = [start..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .method assembly specialname rtspecialname + instance void .ctor(uint64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld uint64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(uint64 start, + uint64 finish) 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 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: bge.s IL_000a + + IL_0004: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0009: ret + + IL_000a: ldarg.1 + IL_000b: ldarg.0 + IL_000c: sub + IL_000d: ldc.i4.1 + IL_000e: conv.i8 + IL_000f: add + IL_0010: ldarg.0 + IL_0011: newobj instance void Test/test@1::.ctor(uint64) + IL_0016: tail. + IL_0018: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_001d: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions([|"--optimize+"|], + """ + module Test + + let a () = uint64 (Array.zeroCreate 10).Length + let b () = uint64 (Array.zeroCreate 20).Length + + let test () = [a ()..b ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(uint64 start) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: ldfld uint64 Test/test@1::start + IL_0006: ldarg.1 + IL_0007: add + IL_0008: ret + } + + } + + .method public static uint64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 4 + .locals init (uint64 V_0, + uint64 V_1) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: stloc.0 + IL_000b: ldc.i4.s 20 + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0012: ldlen + IL_0013: conv.i4 + IL_0014: conv.i8 + IL_0015: stloc.1 + IL_0016: ldloc.1 + IL_0017: ldloc.0 + IL_0018: bge.s IL_0020 + + IL_001a: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_001f: ret + + IL_0020: ldloc.1 + IL_0021: ldloc.0 + IL_0022: sub + IL_0023: ldc.i4.1 + IL_0024: conv.i8 + IL_0025: add + IL_0026: ldloc.0 + IL_0027: newobj instance void Test/test@1::.ctor(uint64) + IL_002c: tail. + IL_002e: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0033: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + /// [start..step..finish] + module RangeStep = + [] + let ``Lone RangeUInt64 with const args when step = 0 lowers to call to invalidArg`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1UL..0UL..5UL] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: ldstr "step" + IL_0005: ldstr "The step of a range cannot be zero." + IL_000a: tail. + IL_000c: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0011: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args when (finish - start) / step + 1 ≤ 0 lowers to empty array`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [5UL..1UL..1UL] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + 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 + test() cil managed + { + + .maxstack 8 + IL_0000: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0005: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with const args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test () = [1UL..2UL..257UL] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field static assembly initonly class Test/test@1 @_instance + .method assembly specialname rtspecialname + instance void .ctor() cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldc.i4.2 + IL_0002: conv.i8 + IL_0003: mul + IL_0004: ldc.i4.1 + IL_0005: conv.i8 + IL_0006: add + IL_0007: ret + } + + .method private specialname rtspecialname static + void .cctor() cil managed + { + + .maxstack 10 + IL_0000: newobj instance void Test/test@1::.ctor() + IL_0005: stsfld class Test/test@1 Test/test@1::@_instance + IL_000a: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x81 + IL_0005: conv.i8 + IL_0006: ldsfld class Test/test@1 Test/test@1::@_instance + IL_000b: tail. + IL_000d: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0012: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args lowers to call to init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let test (start : uint64) (step : uint64) (finish : uint64) = [start..step..finish] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .field public uint64 step + .method assembly specialname rtspecialname + instance void .ctor(uint64 start, + uint64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld uint64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld uint64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld uint64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test(uint64 start, + uint64 step, + uint64 finish) 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 (uint64 V_0) + IL_0000: ldarg.1 + IL_0001: brtrue.s IL_0015 + + IL_0003: ldstr "step" + IL_0008: ldstr "The step of a range cannot be zero." + IL_000d: tail. + IL_000f: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0014: ret + + IL_0015: ldarg.2 + IL_0016: ldarg.0 + IL_0017: sub + IL_0018: ldarg.1 + IL_0019: div + IL_001a: ldarg.1 + IL_001b: add + IL_001c: stloc.0 + IL_001d: ldloc.0 + IL_001e: brtrue.s IL_0026 + + IL_0020: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0025: ret + + IL_0026: ldloc.0 + IL_0027: ldarg.0 + IL_0028: ldarg.1 + IL_0029: newobj instance void Test/test@1::.ctor(uint64, + uint64) + IL_002e: tail. + IL_0030: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0035: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + + [] + let ``Lone RangeUInt64 with dynamic args that are complex exprs stores those in vars before calling init`` () = + CompilerAssert.CompileLibraryAndVerifyILWithOptions(["--optimize+"], + """ + module Test + + let a () = uint64 (Array.zeroCreate 10).Length + let b () = uint64 (Array.zeroCreate 20).Length + let c () = uint64 (Array.zeroCreate 300).Length + + let test () = [a () .. b () .. c ()] + """, + (fun verifier -> verifier.VerifyIL [ + """ + .assembly extern runtime { } + .assembly extern FSharp.Core { } + .assembly assembly + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.FSharpInterfaceDataVersionAttribute::.ctor(int32, + int32, + int32) = ( 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 ) + .hash algorithm 0x00008004 + .ver 0:0:0:0 + } + .mresource public FSharpSignatureData.assembly + { + + + } + .mresource public FSharpOptimizationData.assembly + { + + + } + .module assembly.dll + + .imagebase {value} + .file alignment 0x00000200 + .stackreserve 0x00100000 + .subsystem 0x0003 + .corflags 0x00000001 + + + + + + .class public abstract auto ansi sealed Test + extends [runtime]System.Object + { + .custom instance void [FSharp.Core]Microsoft.FSharp.Core.CompilationMappingAttribute::.ctor(valuetype [FSharp.Core]Microsoft.FSharp.Core.SourceConstructFlags) = ( 01 00 07 00 00 00 00 00 ) + .class auto ansi serializable sealed nested assembly beforefieldinit test@1 + extends class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2 + { + .field public uint64 start + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .field public uint64 step + .custom instance void [runtime]System.Diagnostics.DebuggerBrowsableAttribute::.ctor(valuetype [runtime]System.Diagnostics.DebuggerBrowsableState) = ( 01 00 00 00 00 00 00 00 ) + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + .method assembly specialname rtspecialname + instance void .ctor(uint64 start, + uint64 step) cil managed + { + .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) + .custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) + + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::.ctor() + IL_0006: ldarg.0 + IL_0007: ldarg.1 + IL_0008: stfld uint64 Test/test@1::start + IL_000d: ldarg.0 + IL_000e: ldarg.2 + IL_000f: stfld uint64 Test/test@1::step + IL_0014: ret + } + + .method public strict virtual instance uint64 + Invoke(int32 i) cil managed + { + + .maxstack 8 + IL_0000: ldarg.1 + IL_0001: ldarg.0 + IL_0002: ldfld uint64 Test/test@1::step + IL_0007: mul + IL_0008: ldarg.0 + IL_0009: ldfld uint64 Test/test@1::start + IL_000e: add + IL_000f: ret + } + + } + + .method public static uint64 a() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 b() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4.s 20 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: ret + } + + .method public static uint64 c() cil managed + { + + .maxstack 8 + IL_0000: ldc.i4 0x12c + IL_0005: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_000a: ldlen + IL_000b: conv.i4 + IL_000c: conv.i8 + IL_000d: ret + } + + .method public static class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 + test() cil managed + { + + .maxstack 5 + .locals init (uint64 V_0, + uint64 V_1, + uint64 V_2, + uint64 V_3) + IL_0000: ldc.i4.s 10 + IL_0002: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0007: ldlen + IL_0008: conv.i4 + IL_0009: conv.i8 + IL_000a: stloc.0 + IL_000b: ldc.i4.s 20 + IL_000d: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0012: ldlen + IL_0013: conv.i4 + IL_0014: conv.i8 + IL_0015: stloc.1 + IL_0016: ldc.i4 0x12c + IL_001b: call !!0[] [FSharp.Core]Microsoft.FSharp.Collections.ArrayModule::ZeroCreate(int32) + IL_0020: ldlen + IL_0021: conv.i4 + IL_0022: conv.i8 + IL_0023: stloc.2 + IL_0024: ldloc.1 + IL_0025: brtrue.s IL_0039 + + IL_0027: ldstr "step" + IL_002c: ldstr "The step of a range cannot be zero." + IL_0031: tail. + IL_0033: call !!0 [FSharp.Core]Microsoft.FSharp.Core.Operators::InvalidArg>(string, + string) + IL_0038: ret + + IL_0039: ldloc.2 + IL_003a: ldloc.0 + IL_003b: sub + IL_003c: ldloc.1 + IL_003d: div + IL_003e: ldloc.1 + IL_003f: add + IL_0040: stloc.3 + IL_0041: ldloc.3 + IL_0042: brtrue.s IL_004a + + IL_0044: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1::get_Empty() + IL_0049: ret + + IL_004a: ldloc.3 + IL_004b: ldloc.0 + IL_004c: ldloc.1 + IL_004d: newobj instance void Test/test@1::.ctor(uint64, + uint64) + IL_0052: tail. + IL_0054: call class [FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1 [FSharp.Core]Microsoft.FSharp.Collections.ListModule::Initialize(int32, + class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2) + IL_0059: ret + } + + } + + .class private abstract auto ansi sealed ''.$Test + extends [runtime]System.Object + { + } + """ + ])) + diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index c7cd7c6e1f5..86296c99d7f 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -72,7 +72,9 @@ - + + +