++ only exists in MonkeyC to enable the syntax everyone is used to in places like for loops. It does not pre/post increment like the operator you are used to in C. The code "x++" will compile into "x += 1". You won't be able to use ++ in MonkeyC anywhere that "+= 1" would not work like in the example you posted.
You'll need to change your code to:
var dict = {};
var idx = 0;
dict.put(idx, 2);
idx++;