You are reading a single comment by @DaveNI and its replies. Click here to read the full conversation.
  • @Gordon I wasn't suggesting there are many, the interpreter seems extremely "fluent" - I have only come across 3 issues:

    The first was when closure decided to insert a labeled statement when I used a break or return within a loop - I can't remember the exact code, but I wouldn't expect labels to be implemented in Espruino and if this does occur it is extremely easy to see within the error message.

    The second was as described above - closure identifies that the final semi-colon in a function is superfluous and removes it - Espruino expects a semicolon after a do.. while (and possibly after for loop as @allObjects experienced). The following code is valid but breaks when using simple optimizations

    function test(){
           var i=0;
           do{
                 console.log(i++);
           }
           while (i < 10);
    }
    test();
    

    The final problem was with brackets being removed by the minifier - the precedence of operators must be evaluated slightly differently by Espruino. This was probably the most difficult to debug because an error wasn't thrown (correct answer is 256 but returns 0 when minified because outer brackets are removed by minifier )

    function swap16(val) {
            return ((val & 0xFF) << 8)  | ((val >> 8) & 0xFF) ;
    }
    console.log(swap16(1));
    
    

    I hope this simplified code helps - although minor its the sort of thing that may put beginners off the platform and that would be a pity because it can be extremely enjoyable to work with.

About

Avatar for DaveNI @DaveNI started