WebSharper

There's an issue in the Zafir.4.0.159.36-beta6 where delayed execution functions are eagerly executed in the generated JavaScript.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
namespace SinglePageApplication1

open WebSharper
open WebSharper.JavaScript

[<JavaScript>]
module Client =     
    let openThePit howmany =
        failwithf "Attacked by %i flying monkeys" howmany

    [<SPAEntryPoint>]
    let Main() = 
        let e saveMeDelayedExecution = saveMeDelayedExecution |> (openThePit 1000000)
        printfn "Ensure function isn't optimised away: %A" e
        printfn "Saved!"

will lead to dire failure whereas an equivalent F# console program:

1
2
3
4
5
6
7
8
9
let openThePit howmany =
    failwithf "Attacked by %i flying monkeys" howmany

[<EntryPoint>]
let main argv = 
    let e saveMeDelayedExecution = saveMeDelayedExecution |> (openThePit 10000000)
    printfn "Ensure function isn't optimised away: %A" e
    printfn "Saved!"
    0

will complete successfully:

1
2
Ensure function isn't optimised away: <fun:e@10TT>
Saved!

That's a synthetic version of the problem. We have combinators with mutual dependency that use delayed execution to prevent unbound recursion where this is causing awkward problems.