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=77139 --- shadow/77139 2006-01-02 19:03:46.000000000 -0500 +++ shadow/77139.tmp.6177 2006-01-02 19:03:46.000000000 -0500 @@ -0,0 +1,91 @@ +Bug#: 77139 +Product: Mono: Compilers +Version: 1.1 +OS: +OS Details: Debian Unstable (packages version 1.1.12.1-1) +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Inconsistences when declaring anonymous methods to delegates. + +Description of Problem: +Saying... + +int i; +i = 0; + +...is the same as saying... + +int i = 0; + +...in C#, but saying... + +EventHandler a; +a = delegate { + // ... +}; + +...is being interpreted differently than when saying... + +EventHandler a = delegate { + // ... +} + +Please see the test case for more information. + +Steps to reproduce the problem: +1. Save the test case as a file (e.g. "bug.cs"). +2. Try to compile it (e.g. "mcs bug.cs" or "gmcs bug.cs"). + +Actual Results: +$ mcs bug.cs +bug.cs(18,36): error CS0103: The name `callOnce2' does not exist in the +context of `Bug' +Compilation failed: 1 error(s), 0 warnings + +Expected Results: +$ mcs bug.cs +$ # Compiled correctly + +How often does this happen? +Always. + +Additional Information: +I don't know if this is really a bug. I never read the specs and I can't +currently test with MS .NET to see what happens there, I'm just following +my instincts. + +Test case: +//////////////////////////////////////////// +using System; + +public static class Bug { + public static event EventHandler myEvent; + public static void Main() { + // This works fine + EventHandler callOnce1; + callOnce1 = delegate { + //DoSomethingJustOnce(); + myEvent -= callOnce1; + }; + myEvent += callOnce1; + + // This leads to a compiler error + // bug.cs(18,36): error CS0103: The name `callOnce2' does +not exist in the context of `Bug' + EventHandler callOnce2 = delegate { + //DoSomethingJustOnce(); + myEvent -= callOnce2; + }; + myEvent += callOnce2; + } +} +//////////////////////////////////////////// _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
