From 588ab10b44b0d0e2d8331a8bab6e31d17bad6759 Mon Sep 17 00:00:00 2001 From: Marcio Rinaldi Date: Tue, 20 Sep 2016 13:24:32 -0300 Subject: [PATCH] Fix FS0052 warnings (#1543) --- src/fsharp/FSharp.Core/local.fs | 6 ++++-- src/fsharp/FSharp.Core/map.fs | 2 +- src/fsharp/FSharp.Core/printf.fs | 4 ++-- src/fsharp/FSharp.Core/reflect.fs | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/fsharp/FSharp.Core/local.fs b/src/fsharp/FSharp.Core/local.fs index 6232d9ec3d4..7df2e049e8f 100644 --- a/src/fsharp/FSharp.Core/local.fs +++ b/src/fsharp/FSharp.Core/local.fs @@ -148,10 +148,12 @@ module internal List = let mutable ie = dict.GetEnumerator() if not (ie.MoveNext()) then [] else - let res = freshConsNoTail (keyf ie.Current.Key, ie.Current.Value) + let current = ie.Current + let res = freshConsNoTail (keyf current.Key, current.Value) let mutable cons = res while ie.MoveNext() do - let cons2 = freshConsNoTail (keyf ie.Current.Key, ie.Current.Value) + let current = ie.Current + let cons2 = freshConsNoTail (keyf current.Key, current.Value) setFreshConsTail cons cons2 cons <- cons2 setFreshConsTail cons [] diff --git a/src/fsharp/FSharp.Core/map.fs b/src/fsharp/FSharp.Core/map.fs index 9d16a1d5151..0d5e015b3d3 100644 --- a/src/fsharp/FSharp.Core/map.fs +++ b/src/fsharp/FSharp.Core/map.fs @@ -576,7 +576,7 @@ namespace Microsoft.FSharp.Collections let rec loop () = let m1 = e1.MoveNext() let m2 = e2.MoveNext() - (m1 = m2) && (not m1 || ((e1.Current.Key = e2.Current.Key) && (Unchecked.equals e1.Current.Value e2.Current.Value) && loop())) + (m1 = m2) && (not m1 || let e1c, e2c = e1.Current, e2.Current in ((e1c.Key = e2c.Key) && (Unchecked.equals e1c.Value e2c.Value) && loop())) loop() | _ -> false diff --git a/src/fsharp/FSharp.Core/printf.fs b/src/fsharp/FSharp.Core/printf.fs index 26c9647b86e..c4d6f510e48 100644 --- a/src/fsharp/FSharp.Core/printf.fs +++ b/src/fsharp/FSharp.Core/printf.fs @@ -1094,7 +1094,7 @@ module internal PrintfImpl = mi.Invoke(null, args) let buildPlainFinal(args : obj[], argTypes : Type[]) = - let mi = typeof>.GetMethod("Final" + (argTypes.Length.ToString()), NonPublicStatics) + let mi = typeof>.GetMethod("Final" + (let x = argTypes.Length in x.ToString()), NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else @@ -1103,7 +1103,7 @@ module internal PrintfImpl = mi.Invoke(null, args) let buildPlainChained(args : obj[], argTypes : Type[]) = - let mi = typeof>.GetMethod("Chained" + ((argTypes.Length - 1).ToString()), NonPublicStatics) + let mi = typeof>.GetMethod("Chained" + (let x = (argTypes.Length - 1) in x.ToString()), NonPublicStatics) #if DEBUG verifyMethodInfoWasTaken mi #else diff --git a/src/fsharp/FSharp.Core/reflect.fs b/src/fsharp/FSharp.Core/reflect.fs index 379e0bc79e5..9eee255d042 100644 --- a/src/fsharp/FSharp.Core/reflect.fs +++ b/src/fsharp/FSharp.Core/reflect.fs @@ -128,9 +128,9 @@ module internal Impl = let args = a.ConstructorArguments let flags = match args.Count with - | 1 -> ((args.[0].Value :?> SourceConstructFlags), 0, 0) - | 2 -> ((args.[0].Value :?> SourceConstructFlags), (args.[1].Value :?> int), 0) - | 3 -> ((args.[0].Value :?> SourceConstructFlags), (args.[1].Value :?> int), (args.[2].Value :?> int)) + | 1 -> ((let x = args.[0] in x.Value :?> SourceConstructFlags), 0, 0) + | 2 -> ((let x = args.[0] in x.Value :?> SourceConstructFlags), (let x = args.[1] in x.Value :?> int), 0) + | 3 -> ((let x = args.[0] in x.Value :?> SourceConstructFlags), (let x = args.[1] in x.Value :?> int), (let x = args.[2] in x.Value :?> int)) | _ -> (enum 0, 0, 0) res <- Some flags res