{"issue":{"created_at":"2011-11-16T20:50:38Z","state":"closed","updated_at":"2011-12-12T01:25:51Z","comments":4,"user":{"gravatar_id":"a749cd6560a3b7e5a368d15faa7f2bc0","id":1160680,"url":"https://api.github.com/users/matra774","login":"matra774","avatar_url":"https://secure.gravatar.com/avatar/a749cd6560a3b7e5a368d15faa7f2bc0?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"C# compiler sometimes optimizes 'case/switch' statement by using Dictionary<> that is initialized on first run. This dictionary is stored in member that is ignored by JSIL.\r\n\r\n    int TestSwitchWithoutDefaultTransaltesOK(string input)  // translates ok\r\n    {\r\n      switch (input)\r\n      {\r\n        case \"One\": return 1;\r\n        case \"Two\": return 2;\r\n        case \"Three\": return 3;\r\n        case \"Four\": return 4;\r\n        case \"Five\": return 5;\r\n        case \"Six\": return 6;\r\n        //default: return 0;\r\n      }\r\n      return 0;\r\n    }\r\n\r\n    int TestSwitchWithDefaultFails(string input)   // deos not tranlate OK\r\n    {\r\n      switch (input)\r\n      {\r\n        case \"One\": return 1;\r\n        case \"Two\": return 2;\r\n        case \"Three\": return 3;\r\n        case \"Four\": return 4;\r\n        case \"Five\": return 5;\r\n        case \"Six\": return 6;\r\n        default: return 0;\r\n      }\r\n    }\r\n\r\nThe second one is translated to the following block which contains a reference to a ingnroed member:\r\n\r\n    $asm01.TestHelloWorld.Program.prototype.TestSwitchWithDefaultFails = function (input) {\r\n\tvar num = new JSIL.Variable(0);\r\n\tif (input !== null) {\r\n\t\tif (JSIL.IgnoredMember(\"$$method0x600003a-1\") === null) {\r\n\t\t\tvar expr_18 = JSIL.New(System.Collections.Generic.Dictionary$b2.Of(System.String, System.Int32), \"_ctor$3\", [6]);\r\n\t\t\texpr_18.Add(\"One\", 0);\r\n\t\t\texpr_18.Add(\"Two\", 1);\r\n\t\t\texpr_18.Add(\"Three\", 2);\r\n\t\t\texpr_18.Add(\"Four\", 3);\r\n\t\t\texpr_18.Add(\"Five\", 4);\r\n\t\t\texpr_18.Add(\"Six\", 5);\r\n\t\t\tJSIL.IgnoredMember(\"$$method0x600003a-1\") = expr_18;\r\n\t\t}\r\n\t\tif (JSIL.IgnoredMember(\"$$method0x600003a-1\").TryGetValue(input, /* ref */ num)) {\r\n\t\t\tswitch (num.value) {\r\n\t\t\t\tcase 0: \r\n\t\t\t\t\tvar result = 1;\r\n\t\t\t\t\treturn result;\r\n\t\t\t\tcase 1: \r\n\t\t\t\t\tresult = 2;\r\n\t\t\t\t\treturn result;\r\n\t\t\t\tcase 2: \r\n\t\t\t\t\tresult = 3;\r\n\t\t\t\t\treturn result;\r\n\t\t\t\tcase 3: \r\n\t\t\t\t\tresult = 4;\r\n\t\t\t\t\treturn result;\r\n\t\t\t\tcase 4: \r\n\t\t\t\t\tresult = 5;\r\n\t\t\t\t\treturn result;\r\n\t\t\t\tcase 5: \r\n\t\t\t\t\tresult = 6;\r\n\t\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tresult = 0;\r\n\treturn result;\r\n    }; \r\n\r\n\r\n\r\nIf c# compilers would do something similar also for non-basic-value type keys (such as object references) then this would require a working Dictionary class (mentioned in another case). I doubt, that this is the case.\r\n\r\nSomething similar was alo reported at:\r\nhttps://github.com/nikhilk/scriptsharp/issues/56","assignee":null,"labels":[{"name":"Bug","color":"e10c02","url":"https://api.github.com/repos/kevingadd/JSIL/labels/Bug"}],"id":2261515,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":39,"title":"Translating \"switch\" with several cases produces JSIL.IgnoredMemberReference","html_url":"https://github.com/kevingadd/JSIL/issues/39","closed_at":"2011-12-12T01:25:51Z","url":"https://api.github.com/repos/kevingadd/JSIL/issues/39","milestone":null},"action":"created","comment":{"created_at":"2011-12-12T01:25:51Z","updated_at":"2011-12-12T01:25:51Z","user":{"gravatar_id":"09db625490bbe367c4cb8bad064e6725","id":198130,"url":"https://api.github.com/users/kevingadd","login":"kevingadd","avatar_url":"https://secure.gravatar.com/avatar/09db625490bbe367c4cb8bad064e6725?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I think this is fixed now. There are still some related issues when it comes to code generation, but all the cases I tested generate working code (even if gotos still end up in it sometimes).","id":3101089,"url":"https://api.github.com/repos/kevingadd/JSIL/issues/comments/3101089"}}