[Mono-bugs] [Bug 532571] New: Compiler throws exception when dealing with broken code
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Aug 19 14:53:45 EDT 2009
http://bugzilla.novell.com/show_bug.cgi?id=532571
Summary: Compiler throws exception when dealing with broken
code
Classification: Mono
Product: Mono: Compilers
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Minor
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: rkumpera at novell.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Compile:
using System;
public class Foo<T> where T : IComparable<T>
{
public string Test () {
return null;
}
}
public class Foo
{
public string Test<T> () where T : IComparable<T>
{
return null;
}
}
public static class Driver
{
static void UseBrokenMethod () {
new Foo().Test<int> ();
}
static void UseBrokenType () {
return Foo<int> ().Test ();
}
public static int Main () {
try {
var t = typeof (Foo);
var m = t.GetMethod ("Test");
var gma = m.GetGenericArguments () [0];
var res = gma.GetGenericParameterConstraints () [0];
UseBrokenMethod ();
return 1;
} catch (TypeLoadException) {}
try {
var t = typeof (Foo<>);
var gta = t.GetGenericArguments () [0];
var res = gta.GetGenericParameterConstraints () [0];
UseBrokenType ();
return 2;
} catch (TypeLoadException) {}
return 0;
}
}
Results in:
dd.cs(25,17): error CS0127: `Driver.UseBrokenType()': A return keyword must not
be followed by any expression when method returns void
Internal compiler error at dd.cs(24,21):: exception caught while emitting
MethodBuilder [Driver::UseBrokenType]
Unhandled Exception: System.InvalidOperationException: Type is not generic
at System.Reflection.Emit.TypeBuilder.GetGenericTypeDefinition () [0x00000]
at Mono.CSharp.GenericTypeExpr..ctor (System.Type t,
Mono.CSharp.TypeArguments args, Location l) [0x00000]
at Mono.CSharp.SimpleName.ResolveAsTypeStep (IResolveContext ec, Boolean
silent) [0x00000]
at Mono.CSharp.SimpleName.DoSimpleNameResolve (Mono.CSharp.EmitContext ec,
Mono.CSharp.Expression right_side, Boolean intermediate) [0x00000]
..
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list