diff --git a/src/fsharp/FSharp.Core/list.fs b/src/fsharp/FSharp.Core/list.fs index bf37ab08a1..920f0f0d9f 100644 --- a/src/fsharp/FSharp.Core/list.fs +++ b/src/fsharp/FSharp.Core/list.fs @@ -171,13 +171,13 @@ namespace Microsoft.FSharp.Collections [] let init length initializer = Microsoft.FSharp.Primitives.Basics.List.init length initializer - let rec initConstAcc n x acc = - if n <= 0 then acc else initConstAcc (n-1) x (x :: acc) - [] let replicate count initial = if count < 0 then invalidArg "count" (SR.GetString(SR.inputMustBeNonNegative)) - initConstAcc count initial [] + let mutable result = [] + for i in 0..count-1 do + result <- initial :: result + result [] let iter2 action list1 list2 = diff --git a/src/fsharp/FSharp.Core/local.fs b/src/fsharp/FSharp.Core/local.fs index 8e1b17ea91..3d812fc72c 100644 --- a/src/fsharp/FSharp.Core/local.fs +++ b/src/fsharp/FSharp.Core/local.fs @@ -83,7 +83,7 @@ open System.Collections.Generic module internal List = - let arrayZeroCreate (n:int) = (# "newarr !0" type ('T) n : 'T array #) + let inline arrayZeroCreate (n:int) = (# "newarr !0" type ('T) n : 'T array #) [] let nonempty x = match x with [] -> false | _ -> true diff --git a/src/fsharp/TypeChecker.fs b/src/fsharp/TypeChecker.fs index 5d7a170c2c..58d3b2d87b 100644 --- a/src/fsharp/TypeChecker.fs +++ b/src/fsharp/TypeChecker.fs @@ -5482,7 +5482,7 @@ and TcPat warnOnUpper cenv env topValInfo vFlags (tpenv, names, takenNames) ty p | [SynPatErrorSkip(SynPat.Tuple (false, args, _)) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Tuple (false, args, _)), _))] when numArgTys > 1 -> args // note: we allow both 'C _' and 'C (_)' regardless of number of argument of the pattern - | [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> Array.toList (Array.create numArgTys e) + | [SynPatErrorSkip(SynPat.Wild _ as e) | SynPatErrorSkip(SynPat.Paren(SynPatErrorSkip(SynPat.Wild _ as e), _))] -> List.replicate numArgTys e | [arg] -> [arg] | _ when numArgTys = 0 -> error(Error(FSComp.SR.tcUnionCaseDoesNotTakeArguments(), m)) | _ when numArgTys = 1 -> error(Error(FSComp.SR.tcUnionCaseRequiresOneArgument(), m))