kevingadd/JSIL — Issue #65: enum comparison in if statement (wrong JS generated)
Author: xen2
Created: 2012-02-02 17:30:26+00:00
State: open

I have problem with this test case:

using System;

enum SimpleEnum {
Value1,
Value2,
}

public static class Program {
public static void Main (string[] args) {
var test = SimpleEnum.Value1;

if ((test == SimpleEnum.Value1) || (test == SimpleEnum.Value2))
Console.WriteLine("1");
}
}

It gets translated in strange javascript for the first test (probably because of optimizer):
if (!(JSIL.Cast(test, $asm02.System.Boolean) && (test != $asm01.SimpleEnum.Value2))) {

I will probably take a closer look at it this weekend (if nobody else fixes it before me ;p).