Pretokeniser error?

Posted on
  • Looks like the pretokeniser is acting weirdly. Wanted to do some mindless blinking lights, but the code fails if I save to flash.

    My code:

    setInterval(function() {
      LED1.pulse(1,[10, 100, 10, 200, 20]);
    }, 997);
    

    The error from the Puck:

    Uncaught SyntaxError: Got function expected '{'
     at line 2 col 14 in .bootcde
    setInterval(class function(){LED1.pulse(1,[10,100,10,200,2­0]);},997);
                             ^
    > 
    

    .bootcde downloaded from the puck via the web ide:

    setInterval(class function(){LED1.pulse(1,[10,100,10,200,2­0]);},997);
    

    Output from the browser's JS console when sending (so indeed there are some tokens inside the setInterval):

    "\u0010print()\n\u0010setTime(1719600866­.884);E.setTimeZone(2)\n\u0010require(\"­Storage\").write(\".bootcde\",\"\\nsetIn­terval(\\xc2ª(){LED1.pulse(1,[10,100,10,­200,20]);},997);\",0,58);\n\u0010load()\­n\n"
    

    The same happens with the default "new tab" code too:

    // this JS
    var  on = false;
    setInterval(function() {
      on = !on;
      LED1.write(on);
    }, 500);
    

    Becomes this when saved to flash:

    class var on=class false;
    setInterval(class function(){on=!on;LED1.write(on);},500);­
    

    If I turn off the pretokeniser, it works without any problem.
    If I just send it with shift-enter, that works too.

    Web IDE v0.79.3
    Tested with Puck 1, Espruino 2v23 and 2v22 release. And nRF52840DK, built from latest. Same result.

  • Sorry - thanks for letting me know! I think this was some UTF8/unicode support that got added erroneously converting pretokenised code. I'll get a fix in now.

  • Ok - should be fixed!

  • Thank you Gordon!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Pretokeniser error?

Posted by Avatar for AkosLukacs @AkosLukacs

Actions