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,20]);},997); ^ >
.bootcde downloaded from the puck via the web ide:
.bootcde
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):
setInterval
"\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:
// 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.
@AkosLukacs started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working 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:
The error from the Puck:
.bootcde
downloaded from the puck via the web ide:Output from the browser's JS console when sending (so indeed there are some tokens inside the
setInterval
):The same happens with the default "new tab" code too:
Becomes this when saved to flash:
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.