SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
285 stars 26 forks source link

Support different F# 4.1 quotation representation of tuple args #137

Closed stephen-swensen closed 5 years ago

stephen-swensen commented 6 years ago

See https://github.com/Microsoft/visualfsharp/issues/3698

stephen-swensen commented 5 years ago

Unfortunately, it doesn't appear possible to correctly decompile this case of a function partially applied with a tuple in the first arg, because it has the same exact representation as a function partially applied with all non-tuple args:

let ftupled (a,b) c d = a + b + c + d + 1
<@ ftupled (1,2) @>

> <@ ftupled (1,2) @>;;
val it : Quotations.Expr<(int -> int -> int)> =
  Let (a, Value (1),
     Let (b, Value (2),
          Lambda (c, Lambda (d, Call (None, ftupled, [a, b, c, d])))))
    {CustomAttributes = [NewTuple (Value ("DebugRange"),
          NewTuple (Value ("stdin"), Value (6), Value (3), Value (6), Value (16)))];
     Raw = ...;
     Type = Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32]];}

and

let ftupled a b c d = a + b + c + d + 1
<@ ftupled 1 2 @>

> <@ ftupled 1 2 @>;;
val it : Quotations.Expr<(int -> int -> int)> =
  Let (a, Value (1),
     Let (b, Value (2),
          Lambda (c, Lambda (d, Call (None, ftupled, [a, b, c, d])))))
    {CustomAttributes = [NewTuple (Value ("DebugRange"),
          NewTuple (Value ("stdin"), Value (8), Value (3), Value (8), Value (14)))];
     Raw = ...;
     Type = Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,System.Int32]];}