Advertisement
MarkDPaste

switch parser bug

Apr 1st, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 0.64 KB | None | 0 0
  1.  
  2. // valac 0.15.2 complains with ... :7.2-9.31: error: missing break statement at end of switch section
  3.  
  4. enum CheckType {
  5.     A, B, C;
  6. }
  7.  
  8. static bool checkIt(CheckType ct, int v)
  9. {
  10.     switch (ct)        // Complains here!!
  11.     {
  12.     case CheckType.A: return true;
  13.  
  14.     case CheckType.B:
  15.         if (v == 0) break;
  16.     // Fall thru                                                                                  
  17.     case CheckType.C:
  18.         if (v > 3) return false;
  19.     break;
  20.     }
  21.     return true;
  22. }
  23.  
  24. void main(string[] args)
  25. {
  26.     bool res = checkIt(CheckType.B, args.length);
  27.     stdout.printf("Result is %s\n", res.to_string());
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement