Saltarelle / SaltarelleCompiler

C# to JavaScript compiler – Now http://bridge.net
http://saltarelle-compiler.com
Other
297 stars 74 forks source link

Dictionary issue on Chrome #446

Closed HemingwayGames closed 7 years ago

HemingwayGames commented 7 years ago

Just letting you know that I've come across an issue with the Dictionary implementation in mscorlib on Chrome. My code has been running fine for the last couple of years, but the issue has started over the last couple of days. I'm not having any issues with Firefox btw.

I'm able to reproduce the error with the following code snippit:

        Dictionary<string, string> dict = new Dictionary<string, string>();
        dict["TickerFPS"] = "1";
        dict["Controller/Event_Tick"] = "2";
        LogDebug(dict["TickerFPS"]);
        LogDebug(dict["Controller/Event_Tick"]);

The last line raises a 'Controller/Event_Tick does not exist' exception.

mscorlib creates the following hashes for the 2 keys: 1932751199 -1497097067

It seems mscorelib _get function is not able to access keys with negative values. hasOwnProperty(hash) returns false for the -1497097067 key.

debugger: this.buckets.hasOwnProperty(-1497097067): false

mscorelib code:

_get: function(key) {
    var hash = this.comparer.getObjectHashCode(key);
if (this.buckets.hasOwnProperty(hash)) {
        ***hasOwnProperty returns false for hash value -1497097067

I'm currently using the following Saltarelle packages: Saltarelle.Compiler.2.6.2 Saltarelle.Runtime.2.6.2 Saltarelle.Web.3.1.0

Thanks,

George

n9 commented 7 years ago

See http://stackoverflow.com/questions/41103863/hasownproperty-not-working-in-chrome-for-array

n9 commented 7 years ago

There is also a workaround, see: https://github.com/wordwall/SaltarelleCompiler/commit/470351b98cc9ee1383693b68121fcb2a8a681192

HemingwayGames commented 7 years ago

Thanks for the update