You are reading a single comment by @DaveNI and its replies. Click here to read the full conversation.
  • Interesting:

      //Added "*1" to prevent minifier removing brackets
      function swap16(val) {
        return ((val & 0xFF) << 8) * 1 | ((val >> 8) & 0xFF) * 1;
      }
    

    Gives me hints for solving a similar problem I face in http://forum.espruino.com/conversations/256957 ,
    where minifier removed parentheses and Espruino JS choked on their absence... ;-) ...how can you choke on something that is not there... ok: choking on the statement body not greased with parentheses...

    var f0 = function() { console.log("f0()"); };
    var f1 = function (b) { if (b) for (...) f0(); } ;
    

    in code in Sandbox read with minification on fails (still?) to NOT execute the for statement for

    f1();
    
  • I have come across something similar to that - its because the minifier identifies that the final semi-colon in a function is superfluous and removes it. The Espruino interpreter chokes if there is no semicolon after a loop (in my case a while loop). I added a "return 1;" statement after the loop and all was fixed. Hope this helps.

About

Avatar for DaveNI @DaveNI started