[Mono-bugs] [Bug 671488] New: incorrect CS0159 errors being reported

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Feb 11 19:36:28 EST 2011



           Summary: incorrect CS0159 errors being reported
    Classification: Mono
           Product: Mono: Compilers
           Version: 2.10.x
          Platform: x86
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: msafar at novell.com
        ReportedBy: joe at mistachkin.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:
Gecko/20101203 Firefox/3.6.13

It seems the combination of goto and switch might be triggering incorrect
instances of error CS0159.  Here is a simplified example:

// Program.cs

using System;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            int foo;

            Console.Write("please enter a number (0, 1, or 2): ");
            string line = Console.ReadLine();

            if (int.TryParse(line, out foo))
                switch (foo)
                    case 1:
                            Console.WriteLine("case 1 done");
                        Console.WriteLine("default case");

                        if (foo != 0)
                            Console.WriteLine("going to goto target");
                            goto gotoTarget;

                        Console.WriteLine("default done");

Reproducible: Always

Steps to Reproduce:
1. Save the above sample code as "Program.cs"
2. Attempt to compile the sample code using gmcs.

Actual Results:  
Program.cs(31,34): error CS0159: The label `gotoTarget:' could not be found
within the scope of the goto statement
Compilation failed: 1 error(s), 0 warnings

Expected Results:  
An executable assembly file should be produced.  No errors or warnings should
be generated.

This same code compiles perfectly using Mono 2.8 and Visual Studio 2008.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list