Bug 6378 - mcs fails to find duplicated class names when the declarations are in different files
Summary: mcs fails to find duplicated class names when the declarations are in differe...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-08-03 10:13 UTC by Simon Lindgren
Modified: 2012-08-07 13:31 UTC (History)
1 user (show)

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


Attachments
Solution demonstrating the problem. (3.65 KB, application/x-gzip)
2012-08-03 10:13 UTC, Simon Lindgren
Details


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 FIXED

Description Simon Lindgren 2012-08-03 10:13:20 UTC
Created attachment 2294 [details]
Solution demonstrating the problem.

Using mcs from 374bf4c95e0925084784c0c399ff08a2214bf6dc, no error is reported for class names duplicated in declarations in different files.

Instead, an assembly that makes mcs crash is generated.

See attached example MD solution.

Steps to reproduce:
1. Open solution
2. Build it

Expected result:
Compilation error in LibCompilerCrash on type MyClass, which is declared in two files.

Actual result:
The compiler compiles LibCompilerCrash without warnings or errors. It then tries to read the generated assembly during the compilation of the CompilerCrash terminal application but crashes, probably due to the duplicated name.

Stack trace:

System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[IKVM.Reflection.TypeName,IKVM.Reflection.Type].Add (TypeName key, IKVM.Reflection.Type value) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.PopulateTypeDef () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.ModuleReader.GetTypesImpl (System.Collections.Generic.List`1 list) [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Module.GetTypes () [0x00000] in <filename unknown>:0 
  at IKVM.Reflection.Reader.AssemblyReader.GetTypes () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticImporter.ImportAssembly (IKVM.Reflection.Assembly assembly, Mono.CSharp.RootNamespace targetNamespace) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StaticLoader.LoadReferences (Mono.CSharp.ModuleContainer module) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Marek Safar 2012-08-07 13:31:34 UTC
Fixed in master