sq / JSIL

CIL to Javascript Compiler
http://jsil.org/
Other
1.73k stars 240 forks source link

"TrySetException" problem #915

Open johnwason opened 8 years ago

johnwason commented 8 years ago

I am getting this message a lot when using async/await functions:

Unhandled exception at file:///C:/Users/wasonj/libs/jsil/JSIL/Libraries/JSIL.Core.js line 3915:
Error: 3 candidate(s) for method invocation:
System.Boolean System.Threading.Tasks.TaskCompletionSource`1[System.Object].TrySetException(System.Collections.Generic.IEnumerable`1[System.Exception])
System.Boolean System.Threading.Tasks.TaskCompletionSource`1[System.Object].TrySetException(System.Collections.Generic.IEnumerable`1[System.Runtime.ExceptionServices.ExceptionDispatchInfo])
System.Boolean System.Threading.Tasks.TaskCompletionSource`1[System.Object].TrySetException(System.Exception)`

It seems that JavaScript exceptions are not correctly marshaled by the TrySetException stub. Is there a way to make JavaScript exceptions propagate properly when using async/await?

iskiselev commented 8 years ago

Can you provide some sample to reproduce? Will try to look on it, probably on next week.

johnwason commented 8 years ago

This produces the error message:

 public class TestClass
{
    public void run()
    {
        var noop = run2();
    }

    async Task run2()
    {
        await Task.Delay(10);
        JSIL.Verbatim.Expression("c=new DoesNotExist()");
        await Task.Delay(10);
    }
}