[Mono-bugs] [Bug 74114][Nor] New - [GMCS]Cannot call new on a generic struct type without new constraint
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 26 Mar 2005 12:26:44 -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 marcus@cuda.org.
http://bugzilla.ximian.com/show_bug.cgi?id=74114
--- shadow/74114 2005-03-26 12:26:44.000000000 -0500
+++ shadow/74114.tmp.18122 2005-03-26 12:26:44.000000000 -0500
@@ -0,0 +1,50 @@
+Bug#: 74114
+Product: Mono: Compilers
+Version: 1.1
+OS: SUSE 9.2
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: marcus@cuda.org
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: [GMCS]Cannot call new on a generic struct type without new constraint
+
+Description of Problem:
+Note: This is marked as resolved in bug #68326, the problem still exists in
+mono 1.1.5
+
+You cannot call new on a generic stuct type (that is a generic type with a
+struct constaint) without specifing a new constraint. See code below. Since
+a struct always has a default constructor, the new constraint is not
+needed. MS .NET 2.0 (Feb CTP) does not require the new constraint and will
+not compile with it (Error: The 'new()' constraint cannot be used with the
+'struct' constraint).
+
+
+Steps to reproduce the problem:
+Try to compile this code
+
+class Test<T> where T: struct{
+ public Test(){
+ T s = new T();
+ }
+}
+Actual Results:
+using mono 1.1.5
+test.cs(3) error CS0304: Cannot create an instance of the variable type 'T'
+because it doesn't have the new() constraint
+
+Expected Results:
+should compile fine
+
+How often does this happen?
+
+
+Additional Information: