X10
  1. X10
  2. XTENLANG-1454

Confusing error messages for switch

    Details

    • Number of attachments :
      0

      Description

      The code

      public class CaseBug {
          public static def main(args:Rail[String]!): Void {
             val aByte = args.length > 0 ? Int.parse(args(0)) : 2;
             switch(aByte) {
             case  0 as Byte: Console.OUT.println("A!"); break;
             default: Console.OUT.println((aByte as Byte)+" not legal.");
             }
             switch(aByte as Byte) {
             case  65: Console.OUT.println("A!"); break;
             default: Console.OUT.println((aByte as Byte)+" not legal.");
             }
          }
      }
      

      yields error messages:

      CaseBug.x10:7: Case label must be an byte, char, short, or int.
      CaseBug.x10:10-13: Switch index must be an integer.

      Which is it? and if it may be a byte, well... how the byte A?

        Activity

        Hide
        David Grove added a comment -

        bulk defer of issues to 2.2.3.

        Show
        David Grove added a comment - bulk defer of issues to 2.2.3.
        Hide
        David Grove added a comment -

        bulk defer of 2.3.0 open issues to 2.3.1.

        Show
        David Grove added a comment - bulk defer of 2.3.0 open issues to 2.3.1.
        Hide
        David Grove added a comment -

        bulk defer to 2.3.2

        Show
        David Grove added a comment - bulk defer to 2.3.2
        Hide
        David Grove added a comment -

        bulk defer to 2.4.1.

        Show
        David Grove added a comment - bulk defer to 2.4.1.
        Hide
        David Grove added a comment -

        Updated test case to X10 2.4

        public class CaseBug {
            public static def main(args:Rail[String]) {
               val aByte = args.size > 0 ? Int.parse(args(0)) : 2n;
               switch(aByte) {
               case  0 as Byte: Console.OUT.println("A!"); break;
               default: Console.OUT.println((aByte as Byte)+" not legal.");
               }
               switch(aByte as Byte) {
               case  65: Console.OUT.println("A!"); break;
               default: Console.OUT.println((aByte as Byte)+" not legal.");
               }
            }
        }
        

        It now produces what I would consider to be reasonable and clear error messages:

        [dgrove@linchen myTests]$ x10c++ CaseBug.x10 
        /home/dgrove/x10-trunk/myTests/CaseBug.x10:5: Case label must be of type x10.lang.Int (same as the expression of the enclosing switch), not x10.lang.Byte.
        /home/dgrove/x10-trunk/myTests/CaseBug.x10:5: Case label must be an integral constant.
        /home/dgrove/x10-trunk/myTests/CaseBug.x10:9: Case label must be of type x10.lang.Byte (same as the expression of the enclosing switch), not x10.lang.Long{self==65L}.
        3 errors.
        
        Show
        David Grove added a comment - Updated test case to X10 2.4 public class CaseBug { public static def main(args:Rail[ String ]) { val aByte = args.size > 0 ? Int.parse(args(0)) : 2n; switch (aByte) { case 0 as Byte : Console.OUT.println( "A!" ); break ; default : Console.OUT.println((aByte as Byte )+ " not legal." ); } switch (aByte as Byte ) { case 65: Console.OUT.println( "A!" ); break ; default : Console.OUT.println((aByte as Byte )+ " not legal." ); } } } It now produces what I would consider to be reasonable and clear error messages: [dgrove@linchen myTests]$ x10c++ CaseBug.x10 /home/dgrove/x10-trunk/myTests/CaseBug.x10:5: Case label must be of type x10.lang.Int (same as the expression of the enclosing switch ), not x10.lang. Byte . /home/dgrove/x10-trunk/myTests/CaseBug.x10:5: Case label must be an integral constant. /home/dgrove/x10-trunk/myTests/CaseBug.x10:9: Case label must be of type x10.lang. Byte (same as the expression of the enclosing switch ), not x10.lang. Long {self==65L}. 3 errors.

          People

          • Assignee:
            Unassigned
            Reporter:
            Jonathan Brezin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: