[Mono-bugs] [Bug 69727][Nor] New - [GMCS]: gmcs generates null reference error with misplaced new() constraint

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 19 Nov 2004 18:37:38 -0500 (EST)

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by benmartin@fourthplanet.net.


--- shadow/69727	2004-11-19 18:37:38.000000000 -0500
+++ shadow/69727.tmp.4947	2004-11-19 18:37:38.000000000 -0500
@@ -0,0 +1,74 @@
+Bug#: 69727
+Product: Mono: Compilers
+Version: 1.1
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: benmartin@fourthplanet.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: [GMCS]: gmcs generates null reference error with misplaced new() constraint
+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 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
+in <0x001df> Mono.CSharp.NamespaceEntry:Lookup
+in <0x00038> Mono.CSharp.RootContext:NamespaceLookup
+in <0x0013d> Mono.CSharp.RootContext:LookupType
+in <0x00018> Mono.CSharp.RootContext:LookupType
+in <0x001cf> Mono.CSharp.SimpleName:ResolveAsTypeStep (Mono.CSharp.EmitContext)
+in <0x0001f> Mono.CSharp.Expression:ResolveAsTypeTerminal
+in <0x00203> Mono.CSharp.ConstructedType:ResolveConstructedType
+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.)