2008-07-17 Marek Safar <marek.safar@gmail.com>
authorMarek Safar <marek.safar@gmail.com>
Thu, 17 Jul 2008 09:32:23 +0000 (09:32 -0000)
committerMarek Safar <marek.safar@gmail.com>
Thu, 17 Jul 2008 09:32:23 +0000 (09:32 -0000)
* ecore.cs: Custom error message for a range variable assignment.

svn path=/trunk/mcs/; revision=108118

mcs/mcs/ChangeLog
mcs/mcs/ecore.cs

index 61df9cce6f145ba43ce6eaccc01dc637e5c0e76d..9631ddcb4824fe4acbab1b181eaa906c15e69320 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-17  Marek Safar  <marek.safar@gmail.com>
+
+       * ecore.cs: Custom error message for a range variable assignment.
+
 2008-07-16  Marek Safar  <marek.safar@gmail.com>
 
        * constant.cs, typemanager.cs: Emit empty string ("") as string.Empty field
index e8e0e6f3b86a32a5505d15ec3cdf75e2060dc7dd..c19dbf9254893c81c58d92d1403a5f1f2a9e0321 100644 (file)
@@ -5432,8 +5432,14 @@ namespace Mono.CSharp {
                                //
                                if (getter == null)
                                        return null;
-                               Report.Error (200, loc, "Property or indexer `{0}' cannot be assigned to (it is read only)",
-                                             GetSignatureForError ());
+
+                               if (ec.CurrentBlock.Toplevel.GetTransparentIdentifier (PropertyInfo.Name) != null) {
+                                       Report.Error (1947, loc, "A range variable `{0}' cannot be assigned to. Consider using `let' clause to store the value",
+                                               PropertyInfo.Name);
+                               } else {
+                                       Report.Error (200, loc, "Property or indexer `{0}' cannot be assigned to (it is read only)",
+                                               GetSignatureForError ());
+                               }
                                return null;
                        }