arrow function does not work

Posted on
  • if you try this simple example

    let p = 0;
    function onInit() {
      setInterval(() => {
        //allume la led 50ms
        digitalPulse(LED2, 1, 20);
        console.log((Math.sin(p)+1)/2);//, (Math.cos(p)+1)/2, tab.BUTTONS.NONE);
        p += 0.02;

    and upload, i receive :

    Uncaught SyntaxError: Got ';' expected ','
    at line 1 col 79

    in function called from system

  • Thr 2020.03.05

    Hi @@Mrbbp I just tried the snippet in post #1, commenting out L12, running on a MDBT42Q breakout board and get the following:

     2v03 (c) 2018 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:

    First, try commenting out L6 and re-run the test. If successful, then it is most likely the first argument's value for the 'pin' parameter.­bal_digitalPulse

    Second, the Uncaught SyntaxError output is parsed different than L7    Are we sure the Exact code block is being supplied, or was this a trimmed down version for demonstration?

    console.log((Math.sin(p)+1)/2);//, (Math.cos(p)+1)/2, tab.BUTTONS.NONE);

    comma vs semi-colon allowing the comment to be treated as code

    Third, Please post the results of process.env so that we may understand the environment better.

    Full set of reference links to check out at:

    Writing an effective forum post­335009/

  • @robin

    this is the exact code... copy/paste
    the pb does not come from the digitalPulse. If i comment all the. line in the block the error stay...

    i use minification (esprima), if i remove it, it works.
    with or without checked option, it does not work!


    VERSION: "2v04",
      GIT_COMMIT: "3956264e",
      BOARD: "PICO_R1_3",
      FLASH: 393216, RAM: 98304,
      SERIAL: "5a004e00-04513634-30323836",
      CONSOLE: "USB",
      MODULES: "Flash,Storage,hea" ... "v,crypto,neopixel",
      EXPTR: 536871212 }
  • Yes, Esprima doesn't like arrow functions :/
    Try closure compiler with remove-whitespace or simple optimizations.

  • @AkosLukacs
    the other minification are online... i'm coding in train (now) and there is lot of "white zone" :/
    online access can't be a statement! sorry :)

    i don't minify the code

  • Are you using the 'Chrome App' (or native) IDE, rather than (the website still works offline!)

    Exactly this error has been fixed in for a while, but the changes may not have made it into the Chrome app yet.

    i don't minify the code

    I'd check your settings again. The code in the error message ..((Math.sin(p)+1)/2),p+=0.02;,50); has definitely been minified.

    If you turn off minification it'll work.

  • Hello @Gordon

    i use the Chrome App... (since the first time...) sometime i open the IDE whitout an internet connection, therefore i got into my habits to use the Chrome app.

    In an old project i have to minify code to put all the code in the pico, i checked the minify option on and never unchecked.

    As my skills level increase in js, i want to write code in the same way in espruino and web... and arrow function are really cool feature (for me)
    I've unchecked the minify option for the avoid the esprima error...


  • Glad that fixed it! The Chrome app will be updated soon, but I'm afraid in about 2-3 months Google will actually remove the Chrome app completely, so you won't have the option!

  • Oh that’s a bad news!

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

arrow function does not work

Posted by Avatar for Mrbbp @Mrbbp