[Mono-list] Internal compiler error
Baltasar GarcĂa Perez-Schofield
baltasarq at gmail.com
Fri Dec 23 13:40:13 UTC 2016
Hi, Xamarin,
I've found an error in the mono compiler (by accident), with a program
which includes a generic class (the error I am reporting does not happen
with a regular class). If I compile it this way:
==
//using System;
public sealed class Foo<T>: IComparable, IComparable<Foo<T>> {
//private class NestedClass {}
public int CompareTo(object o)
{
return 0;
}
public int CompareTo(Foo<T> q2)
{
return 0;
}
}
==
Then I get the expected output:
==
$ mcs -target:library error.cs
error.cs(3,29): error CS0246: The type or namespace name `IComparable'
could not be found. Are you missing `System' using directive?
error.cs(3,42): error CS0246: The type or namespace name `IComparable'
could not be found. Are you missing `System' using directive?
Compilation failed: 2 error(s), 0 warnings
==
If I delete the comment mark in the first line then the error is solved. So
far, so good.
If both lines (the first one, and the one about the nested class) are
uncommented, then it compiles without a glitch.
But when I uncomment the nestedclass, and comment the first line (i.e.,
//using System), I get:
==
$ mcs -target:library error.cs
Unhandled Exception:
Mono.CSharp.InternalErrorException: error.cs(3,21): Foo<T> --->
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException (System.ExceptionResource
resource) [0x0000b] in <8f2c484307284b51944a1a13a14c0266>:0
at System.Collections.Generic.Dictionary`2[TKey,TValue].Insert (TKey key,
TValue value, System.Boolean add) [0x0008e] in
<8f2c484307284b51944a1a13a14c0266>:0
at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key,
TValue value) [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0
at Mono.CSharp.MemberCache.InflateTypes (Mono.CSharp.MemberCache
inflated_cache, Mono.CSharp.TypeParameterInflator inflator) [0x00086] in
<9494102539fd45149c591ed0d231421b>:0
at Mono.CSharp.InflatedTypeSpec.InitializeMemberCache (System.Boolean
onlyTypes) [0x0006d] in <9494102539fd45149c591ed0d231421b>:0
at Mono.CSharp.InflatedTypeSpec.get_BaseType () [0x0001c] in
<9494102539fd45149c591ed0d231421b>:0
==
Hope this helps to fix the compiler.
-- Baltasar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-list/attachments/20161223/557cc636/attachment.html>
More information about the Mono-list
mailing list