kevingadd/JSIL — Issue #36: Bug: Dictionary initializer only initializes keys, but not values
Author: matra774
Created: 2011-11-12 21:29:10+00:00
State: open

Hi,

The following code

var cache = new Dictionary()
{
{"key1","value1" },
};

Generates wrong Javascript. Note that only key is initialized, but not the value. I'm guessing that the wrong initializer is called. The following code is generated:

var cache = JSIL.Cast(JSIL.New(System.Collections.Generic.Dictionary$b2.Of(System.String, System.String), "_ctor$0", [])
.__Initialize__(["key1"]), System.Collections.Generic.Dictionary$b2.Of(System.String, System.String));

Here is the version of JavaScript with all optimizations turned off:

var cache = JSIL.Cast((JSIL.New(System.Collections.Generic.Dictionary$b2.Of(System.String, System.String), "_ctor$0", [])
= new JSIL.CollectionInitializer("key1")), System.Collections.Generic.Dictionary$b2.Of(System.String, System.String));

Matra