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:

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

    The error from the Puck:

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

    .bootcde downloaded from the puck via the web ide:

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

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

    1. "\u0010print()\n\u0010setTime(1719600866.884);E.setTimeZone(2)\n\u0010require(\"Storage\").write(\".bootcde\",\"\\nsetInterval(\\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:

    1. // this JS
    2. var on = false;
    3. setInterval(function() {
    4. on = !on;
    5. LED1.write(on);
    6. }, 500);

    Becomes this when saved to flash:

    1. class var on=class false;
    2. 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
    • $ Donate
About

Pretokeniser error?

Posted by Avatar for AkosLukacs @AkosLukacs

Actions