Bug 51163 - mcs build results in "An item with the same key has already been added"
Summary: mcs build results in "An item with the same key has already been added"
Status: RESOLVED DUPLICATE of bug 51166
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-12-30 22:57 UTC by Neale Ferguson
Modified: 2017-01-02 18:12 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 51166

Description Neale Ferguson 2016-12-30 22:57:07 UTC
Compiling the following on .NET or with pre-4.8 mcs -

using System;
using System.Collections.Generic;

namespace fail22
{
                        class MainClass
                        {
                                public static void Main (string[] args)
                                {
                                        var persistable = new Dictionary<int[], double>();
                                        persistable.Add(new int[0],1 );
                                        persistable.Add(new int[0], 1);
                                }
                        }
}

results in a clean build and clean execution.

Under 4.8 the build works but the execution results in:

System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x0000b] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) [0x0008e] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at fail22.MainClass.Main (System.String[] args) [0x00020] in <f9c1eaf2944c468e8547a223d2b70277>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An item with the same key has already been added.
  at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource resource) [0x0000b] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key, TValue value, System.Boolean add) [0x0008e] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <1912473ffe6945af9cb4f31c6bf575b9>:0 
  at fail22.MainClass.Main (System.String[] args) [0x00020] in <f9c1eaf2944c468e8547a223d2b70277>:0 


Neale
Comment 1 Marek Safar 2017-01-02 18:12:17 UTC

*** This bug has been marked as a duplicate of bug 51166 ***