Hi,
I entered this bug into bugzilla yesterday. This patch should fix it (at
least, I've tested it and it appears to fix it). I've also added closing
brackets to some comments, since they confused emacs and stopped the "go
to matching brace" stuff working.
I've attached the patch and a new test for mcs/errors.
Andrew
- www.tardis.ed.ac.uk/~adb -
Index: errors/ChangeLog
===================================================================
RCS file: /mono/mcs/errors/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 ChangeLog
--- errors/ChangeLog 25 Jun 2002 19:23:14 -0000 1.1
+++ errors/ChangeLog 26 Jun 2002 16:09:11 -0000
@@ -1,3 +1,7 @@
+2002-06-26 <[EMAIL PROTECTED]>
+
+ * cs1501-3.cs: Added new test for struct ctr typechecks.
+
2002-06-24 Andrew Birkett <[EMAIL PROTECTED]>
* fail: cs0121.cs, cs0157.cs and cs1501.cs no longer fail.
Index: mcs/ChangeLog
===================================================================
RCS file: /mono/mcs/mcs/ChangeLog,v
retrieving revision 1.530
diff -u -r1.530 ChangeLog
--- mcs/ChangeLog 25 Jun 2002 19:23:48 -0000 1.530
+++ mcs/ChangeLog 26 Jun 2002 16:09:13 -0000
@@ -1,3 +1,8 @@
+2002-06-26 <[EMAIL PROTECTED]>
+
+ * expression.cs: Fix to struct constructor matching. Also paired
+ up braces in comments so emacs can jump over blocks of code.
+
2002-06-25 Andrew Birkett <[EMAIL PROTECTED]>
* driver.cs: Made error handling more consistent. Errors now
Index: mcs/expression.cs
===================================================================
RCS file: /mono/mcs/mcs/expression.cs,v
retrieving revision 1.280
diff -u -r1.280 expression.cs
--- mcs/expression.cs 20 Jun 2002 19:10:52 -0000 1.280
+++ mcs/expression.cs 26 Jun 2002 16:09:14 -0000
@@ -3790,7 +3790,7 @@
/// The MethodBase argument might be null if the
/// emission of the arguments is known not to contain
/// a `params' field (for example in constructors or other routines
- /// that keep their arguments in this structure
+ /// that keep their arguments in this structure)
/// </summary>
public static void EmitArguments (EmitContext ec, MethodBase mb,
ArrayList arguments)
{
@@ -4088,12 +4088,14 @@
Arguments, loc);
}
-
- if (method == null && !is_struct) {
- Error (1501, loc,
- "New invocation: Can not find a constructor for
" +
- "this argument list");
- return null;
+
+ if (method == null) {
+ if (!is_struct || Arguments.Count > 0) {
+ Error (1501, loc,
+ "New invocation: Can not find a
+constructor for " +
+ "this argument list");
+ return null;
+ }
}
return this;
}
@@ -5267,7 +5269,7 @@
{
//
// We are the sole users of ResolveWithSimpleName (ie, the
only
- // ones that can cope with it
+ // ones that can cope with it)
//
Expression original = expr;
expr = expr.ResolveWithSimpleName (ec);
// CS1501: No overload for method 'X' takes '2' arguments
public struct X {
public X(int i) { }
public static void Main() {
X x = new X("foo", "bar");
}
}