mail-archives/mono-bugs/2003-March/004063.html

126 строки
4.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-bugs] [Bug 38935][Nor] New - mcs allows derived class constructors to write to readonly fields of a base class
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:bugzilla-daemon%40rocky.ximian.com">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="004056.html">
<LINK REL="Next" HREF="004064.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-bugs] [Bug 38935][Nor] New - mcs allows derived class constructors to write to readonly fields of a base class
</H1>
<B>bugzilla-daemon@rocky.ximian.com
</B>
<A HREF="mailto:bugzilla-daemon%40rocky.ximian.com"
TITLE="[Mono-bugs] [Bug 38935][Nor] New - mcs allows derived class constructors to write to readonly fields of a base class">bugzilla-daemon@rocky.ximian.com
</A><BR>
<I>Fri, 28 Feb 2003 23:56:47 -0500 (EST)</I>
<P><UL>
<LI> Previous message: <A HREF="004056.html">[Mono-bugs] Forget aging and dieting forever! 0306Dmpk0-919dSOv27-18
</A></li>
<LI> Next message: <A HREF="004064.html">[Mono-bugs] [Bug 38935][Nor] Changed - mcs allows derived class constructors to write to readonly fields of a base class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4063">[ date ]</a>
<a href="thread.html#4063">[ thread ]</a>
<a href="subject.html#4063">[ subject ]</a>
<a href="author.html#4063">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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 <A HREF="mailto:mathpup@mylinuxisp.com.">mathpup@mylinuxisp.com.</A>
<A HREF="http://bugzilla.ximian.com/show_bug.cgi?id=38935">http://bugzilla.ximian.com/show_bug.cgi?id=38935</A>
--- shadow/38935 Fri Feb 28 23:56:47 2003
+++ shadow/38935.tmp.29457 Fri Feb 28 23:56:47 2003
@@ -0,0 +1,62 @@
+Bug#: 38935
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+ReportedBy: <A HREF="mailto:mathpup@mylinuxisp.com">mathpup@mylinuxisp.com</A>
+QAContact: <A HREF="mailto:mono-bugs@ximian.com">mono-bugs@ximian.com</A>
+TargetMilestone: ---
+URL:
+Cc:
+Summary: mcs allows derived class constructors to write to readonly fields of a base class
+
+Description of Problem:
+
+When a class declared a &quot;readonly&quot; field, only constructors of that class should be
+able to write to that field. However, mcs permits a derived-class constructor to write
+to that field, which is incorrect (ECMA 17.4.2).
+
+
+Steps to reproduce the problem:
+1. Compile program below: mcs readonly.cs
+
+Actual Results:
+
+``Compilation succeeded''
+
+
+Expected Results:
+
+readonly.cs(11,3): error CS0191: A readonly field cannot be assigned to
+(except in a constructor or a variable initializer)
+
+
+How often does this happen?
+
+Always
+
+Additional Information:
+
+//Compile: mcs readonly.cs
+public class Base
+{
+ public readonly int x;
+}
+
+
+public class Derived: Base
+{
+ public Derived()
+ {
+ x = 0;
+ }
+
+
+ public static void Main() {}
+}
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="004056.html">[Mono-bugs] Forget aging and dieting forever! 0306Dmpk0-919dSOv27-18
</A></li>
<LI> Next message: <A HREF="004064.html">[Mono-bugs] [Bug 38935][Nor] Changed - mcs allows derived class constructors to write to readonly fields of a base class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4063">[ date ]</a>
<a href="thread.html#4063">[ thread ]</a>
<a href="subject.html#4063">[ subject ]</a>
<a href="author.html#4063">[ author ]</a>
</LI>
</UL>
</body></html>