[Mono-list] Is this a new bug?

Nikki Locke nikki at trumphurst.com
Fri Jul 14 13:00:45 EDT 2006


using System;

namespace SpecSoft.Lib {

  public class Test {

    public static void Main() {
      string model = "TSP100";

      System.Console.WriteLine("switch on '{0}'", model);

      switch(model) {
        case "wibble":
        case null:
          System.Console.WriteLine("case null !!!!");
          break;
        case "TSP100":
          System.Console.WriteLine("case TSP100");
          break;
      }
    }

  }
}

[nikki at router Test]$ mcs Test.cs
[nikki at router Test]$ mono Test.exe
switch on 'TSP100'
case null !!!!

Reordering the first two cases to

using System;

namespace SpecSoft.Lib {

  public class Test {

    public static void Main() {
      string model = "TSP100";

      System.Console.WriteLine("switch on '{0}'", model);

      switch(model) {
        case null:
        case "wibble":
          System.Console.WriteLine("case null !!!!");
          break;
        case "TSP100":
          System.Console.WriteLine("case TSP100");
          break;
      }
    }

  }
}

Gives the correct output:

[nikki at router Test]$ mcs Test.cs
[nikki at router Test]$ mono Test.exe
switch on 'TSP100'
case TSP100

Using mono 1.1.15 on CentOS 4 Linux.

The same code, compiled using MS C#, but run under Mono, gives the correct 
output.

Posted as bug 78860, as I couldn't find anything similar.

-- 
Nikki Locke, Trumphurst Ltd.      PC & Unix consultancy & programming
http://www.trumphurst.com/




More information about the Mono-list mailing list