[Mono-bugs] [Bug 23513] New - compile-error expected on call to non-static method from ctor initializer
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
16 Apr 2002 18:33:36 -0000
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 loz@cable.a2000.nl.
http://bugzilla.ximian.com/show_bug.cgi?id=23513
--- shadow/23513 Tue Apr 16 14:33:36 2002
+++ shadow/23513.tmp.23061 Tue Apr 16 14:33:36 2002
@@ -0,0 +1,70 @@
+Bug#: 23513
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: loz@cable.a2000.nl
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: compile-error expected on call to non-static method from ctor initializer
+
+I've got a simple test program that compiles using mcs, but doesn't compile
+using csc. Par. 17.10.1 of the C# spec says that this program should indeed
+give a compile-time error.
+
+PS. The funny thing is that the output from mcs runs fine in the MS runtime
+:)
+
+See output and program below:
+
+
+$ csc Test.cs
+Microsoft (R) Visual C# .NET Compiler version 7.00.9466
+for Microsoft (R) .NET Framework version 1.0.3705
+Copyright (C) Microsoft Corporation 2001. All rights reserved.
+
+Test.cs(10,25): error CS0120: An object reference is required for the
+nonstatic
+ field, method, or property 'Test.Add8(int)'
+
+
+$ mcs Test.cs
+
+$ _
+
+------------------------------------------
+
+using System;
+using System.Threading;
+using System.Reflection;
+using System.Reflection.Emit;
+
+public class Test {
+
+ public Test () : this (Add8(4), 6) {
+ string hostName = System.Net.Dns.GetHostName ();
+ Console.WriteLine ("Hostname: " + hostName);
+ }
+
+ public Test (int i, int j) {
+ Console.WriteLine ("GOT : " + i + " : " + j);
+ }
+
+
+ public static void Main (String[] args) {
+ Test t = new Test ();
+ }
+
+ private int Add8 (int i) {
+ return i + 8;
+ }
+
+}