Bugzilla – Bug 316495
[GMCS]: gmcs generates null reference error with misplaced new() constraint
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by benmartin@fourthplanet.net 2004-11-19 18:37:38 MST ---- When compiling this code: using System; class A<T> where T: new(), IComparable { } class B<U,V> where V: A<U> { } class Driver { public static void Main () { A<int> a_int; B<int,A<int>> b_stuff; } } gmcs does this: ALPHA SOFTWARE: Mono C# Compiler 1.1.2.0 for Generics gmcs_error.cs(5) error CS0401: The new() constraint must be last. Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object in <0x00085> Mono.CSharp.DeclSpace:CheckAccessLevel (System.Type) in <0x00085> Mono.CSharp.Namespace:Lookup (Mono.CSharp.DeclSpace,string,Mono.CSharp.Location) in <0x001df> Mono.CSharp.NamespaceEntry:Lookup (Mono.CSharp.DeclSpace,string,int,bool,Mono.CSharp.Location) in <0x00038> Mono.CSharp.RootContext:NamespaceLookup (Mono.CSharp.DeclSpace,string,int,Mono.CSharp.Location) in <0x0013d> Mono.CSharp.RootContext:LookupType (Mono.CSharp.DeclSpace,string,bool,int,Mono.CSharp.Location) in <0x00018> Mono.CSharp.RootContext:LookupType (Mono.CSharp.DeclSpace,string,bool,Mono.CSharp.Location) in <0x001cf> Mono.CSharp.SimpleName:ResolveAsTypeStep (Mono.CSharp.EmitContext) in <0x0001f> Mono.CSharp.Expression:ResolveAsTypeTerminal (Mono.CSharp.EmitContext) in <0x00203> Mono.CSharp.ConstructedType:ResolveConstructedType (Mono.CSharp.EmitContext) in <0x002f8> Mono.CSharp.Constraints:Resolve (Mono.CSharp.EmitContext) in <0x00031> Mono.CSharp.TypeParameter:Resolve (Mono.CSharp.DeclSpace) in <0x0056d> Mono.CSharp.TypeContainer:DefineType () in <0x003ea> Mono.CSharp.RootContext:ResolveTree () in <0x00c08> Mono.CSharp.Driver:MainDriver (string[]) in <0x0001f> Mono.CSharp.Driver:Main (string[]) (If the class B<U,V> is taken out the above code is handled without the compiler crashing.) ---- Additional Comments From martin@ximian.com 2004-12-08 14:18:01 MST ---- Fixed.