sq / JSIL

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

Unsigned comparisons work incorrect #1037

Open iskiselev opened 7 years ago

iskiselev commented 7 years ago

Looks like JSIL ignore whether comparison should be down with unsigned values. Here is test case:

.assembly Hello {}
.assembly extern mscorlib {}

.class public abstract sealed Program
    extends [mscorlib]System.Object
{
    .method static void Main()
    {
        .entrypoint
        .maxstack 1
        ldc.i4       -1
        ldc.i4.5 
        ble.un.s     TRUE
        ldstr        "Hello, world!"
        call         void [mscorlib]System.Console::WriteLine(string)
        TRUE:
        ret
    }
}

It means if ((uint)-1 >5) Console.WriteLine("HelloWorld") but was translated as:

    if (-1 > 5) {
      $T00().WriteLine("Hello, world!");
    }

Roslyn use such expressions pretty much within async state machines with try/catch statements.