Discussion Area

ask questions, discuss topics, solve problems

This is a public Discussion Area  publicRSS

Thread

    • Be aware of broken statements inside your...
      Thread posted Jul 19 by Rostislav Siryk
      76 Views, 0 Comments
      Title:
      Be aware of broken statements inside your switch...case blocks!
      Content:

      Here is a compiler bug, which can make your life a nightmare when you are not aware of it. Maybe, it is not very popular situation, but sometimes it is enough to spens a hour fighting with the code like this, where error is present, but no compiler error is given:

      ...
      
      case newMessageByUser:
      
       var html:String = "11";
      
       html = '<h2>@<a href="'+cnf.juickBaseURL+uname+'">'+uname+'</a>:</h2> '+
      
       '<p class="replyQuote">'+juick+'</p>'+
      
       '<p><a href="event:LinkEventReplyTo:'+mid+'">Reply to #'+mid+'</a>, ' +
      
       'Web: <a href="'+murl+'">'+murl'</a></p>';
      
       trace("html=" + html");
      
       break;
      
      ...
      

      The safe technique to discover such errors is to wrap the whole "case: " block content in the curly braces, which will raise compiler error to inform you where your error is:

      ...
      
      case newMessageByUser:
      
      {
      
       var html:String = "11";
      
       html = '<h2>@<a href="'+cnf.juickBaseURL+uname+'">'+uname+'</a>:</h2> '+
      
       '<p class="replyQuote">'+juick+'</p>'+
      
       '<p><a href="event:LinkEventReplyTo:'+mid+'">Reply to #'+mid+'</a>, ' +
      
       'Web: <a href="'+murl+'">'+murl'</a></p>';
      
       trace("html=" + html");
      
       break;
      
      }
      
      ...
      

      Have fun :)

      Rost