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 [EMAIL PROTECTED]

http://bugzilla.ximian.com/show_bug.cgi?id=80279

--- shadow/80279        2006-12-16 15:03:52.000000000 -0500
+++ shadow/80279.tmp.22004      2006-12-16 15:03:52.000000000 -0500
@@ -0,0 +1,115 @@
+Bug#: 80279
+Product: Mono: Compilers
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: [EMAIL PROTECTED]                            
+ReportedBy: [EMAIL PROTECTED]               
+QAContact: [EMAIL PROTECTED]
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: No error reported for assigning by index to returned struct
+
+Description of Problem:
+
+Attempting to alter a struct being returned as 
+the value for a property is correctly flagged with 
+an error, in case the struct is altered by
+assigning to a member. But when that same return value
+is altered by assigning to an indexer, no error
+is returned.
+
+Hmm, not sure I got the terminology right here, 
+see below for an example.
+
+
+Steps to reproduce the problem:
+
+1. put the following code in a file, e.g. t.cs
+
+using System;
+
+public struct vec3
+{
+       public vec3(int xval, int yval, int zval)
+       {
+               x = xval;
+               y = yval;
+               z = zval;
+       }
+       
+       public override string ToString()
+       {
+               return String.Format("(vec3: {0}, {1}, {2})", x, y, z);
+       }
+       
+       public int this[int i]
+       {
+               set 
+               {
+                       Console.WriteLine("setter!");
+                       if (i == 0)
+                               x = value;
+                       else if (i == 1)
+                               y = value;
+                       else if (i == 2)
+                               z = value;
+               }
+       }
+       
+       public int x, y, z;
+};
+
+class Test
+{
+       public static void Main()
+       {
+               Test t = new Test();
+               
+                // (1) gmcs trips (correctly) over this line...
+               t.v.x = 9;                      
+
+                // (2) ...but not over this one
+               //t.v[0] = 9;
+       }       
+       
+       public Test()
+       {
+               m_value = new vec3(1,2,3);
+       }               
+               
+       public  vec3 v  { get { return m_value; } }             
+       
+       protected vec3  m_value;
+};
+
+2. compile with
+
+gmcs -out:t.exe t.cs
+
+An error gets (correctly) reported:
+
+t.cs(42,5): error CS1612: Cannot modify the return value of `Test.v'
+because it is not a variable
+Compilation failed: 1 error(s), 0 warnings
+
+3. Comment out line marked with (1), remove comment on
+line marked with (2)
+
+4. compile again
+
+no error reported
+
+
+I don't know what the MS compiler does with this case.
+
+
+Expected result:
+
+An error being reported for both cases
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to