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
287 stars 25 forks source link

Decompiler Bug: active patterns don't produce correct F# code #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example,

val it : unit = ()
> source 
        <@  
            match "hello world" with
            | InterpretedMatch @"llo" _ -> true
            | _ -> false
        @>;;
val it : string =
  "let matchValue = "hello world" in let activePatternResult = RegexUtils.|InterpretedMatch|_| "llo" matchValue in (match activePatternResult with | Some(_) -> true | _ -> false) && true"

However, as we learned with UnionCaseTest, the best output we can produced for 
even "simple" discriminant union or here active pattern pattern matching 
expressions is too complex to be helpful, therefore we urge Unquote users to 
avoid pattern matching in assertions and give this issue Low priority.

Original issue reported on code.google.com by stephen....@gmail.com on 21 Feb 2011 at 3:18

GoogleCodeExporter commented 9 years ago
Investigation show that active patterns are compiled down to static methods for 
all forms and in all contexts with the key distinguishing feature being that 
the method name begins and ends with a pipe.

Original comment by stephen....@gmail.com on 10 Apr 2012 at 11:30

GoogleCodeExporter commented 9 years ago
Correction: local active patterns have a mangled name, e.g.

Test 'DecompilationTests.issue 11: local active pattern' failed: 

decompile <@ <fun:|LAP|_|@892> 0 1 @> = "(|LAP|_|) 0 1"
"<fun:|LAP|_|@892> 0 1" = "(|LAP|_|) 0 1"
false

    C:\Users\Stephen\Documents\Visual Studio 2010\Projects\Unquote\code\UnquoteTests\DecompilationTests.fs(893,0): at DecompilationTests.issue 11: local active pattern()

Original comment by stephen....@gmail.com on 11 Apr 2012 at 1:00

GoogleCodeExporter commented 9 years ago
Marking this issue as fixed, the local active pattern mangled names mentioned 
previously is actually a more general issue addressed by by issue 79.

Original comment by stephen....@gmail.com on 11 Apr 2012 at 1:24

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 11 Apr 2012 at 8:46