提交 c4df147c 编写于 作者: D Don Syme 提交者: Kevin Ransom (msft)

fix 2661 (#2807)

* fix 2661

* add test
上级 91927083
......@@ -6444,6 +6444,20 @@ let MultiLambdaToTupledLambda g vs body =
tupledv, untupler body
let (|RefTuple|_|) expr =
match expr with
| Expr.Op (TOp.Tuple (TupInfo.Const false),_,args,_) -> Some args
| _ -> None
let MultiLambdaToTupledLambdaIfNeeded g (vs,arg) body =
match vs,arg with
| [],_ -> failwith "MultiLambdaToTupledLambda: expected some argments"
| [v],_ -> [(v,arg)],body
| vs,RefTuple args when args.Length = vs.Length -> List.zip vs args,body
| vs,_ ->
let tupledv, untupler = untupledToRefTupled g vs
[(tupledv, arg)], untupler body
//--------------------------------------------------------------------------
// Beta reduction via let-bindings. Reduce immediate apps. of lambdas to let bindings.
// Includes binding the immediate application of generic
......@@ -6495,8 +6509,9 @@ let rec MakeApplicationAndBetaReduceAux g (f, fty, tyargsl : TType list list, ar
match tryStripLambdaN argsl.Length f with
| Some (argvsl, body) ->
assert (argvsl.Length = argsl.Length)
let argvs,body = List.mapFoldBack (MultiLambdaToTupledLambda g) argvsl body
mkLetsBind m (mkCompGenBinds argvs argsl) body
let pairs,body = List.mapFoldBack (MultiLambdaToTupledLambdaIfNeeded g) (List.zip argvsl argsl) body
let argvs2, args2 = List.unzip (List.concat pairs)
mkLetsBind m (mkCompGenBinds argvs2 args2) body
| _ ->
mkExprApplAux g f fty argsl m
......
......@@ -2,6 +2,8 @@ namespace ThisNamespaceHasToBeTheSame
#nowarn "9"
open System
open System.Runtime.InteropServices
[<Struct>]
......@@ -131,3 +133,28 @@ do()
[<System.Runtime.CompilerServices.InternalsVisibleToAttribute("lib3--optimize")>]
do()
[<NoEquality; NoComparison>]
[<Struct>]
type StructInt32 =
val mutable Value: int32
new(value) = { Value = value }
static member Write(value, x: StructInt32 byref) =
x.Value <- value;
static member inline InlineWrite(value, x: StructInt32 byref) =
x.Value <- value;
module PeverifyTest =
// The test here is simply to peverify the code
let ``StaticWriteResultANewValue`` () =
let mutable v = StructInt32(3);
StructInt32.Write(2, &v);
let result = v.Value
(2, result)
// The test here is simply to peverify the code
let ``StaticInlineWriteResultANewValue`` () =
let mutable v = StructInt32(3)
StructInt32.InlineWrite(2, &v)
let result = v.Value
(2, result)
......@@ -1586,6 +1586,8 @@ module OptimizationTests =
fsc cfg "%s -g --optimize- --target:library -o:lib.dll" cfg.fsc_flags ["lib.fs"; "lib2.fs"]
peverify cfg "lib.dll "
fsc cfg "%s -g --optimize- --target:library -o:lib3.dll -r:lib.dll " cfg.fsc_flags ["lib3.fs"]
fsc cfg "%s -g --optimize- -o:test.exe -r:lib.dll -r:lib3.dll" cfg.fsc_flags ["test.fs "]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册