chrome IDE error with a let in a switch case

Posted on
  • Hello,

    i find a strange behaviour of the chrome ide with a pico with v2.00 firmware
    If i use a let in a switch case block, IDE generate an error

    Error: Line 15: Unexpected token let
    

    i'm not not sure why it's wrong?
    in an html page with the code it does not generate error
    and for my point of view i could legaly use a let in the block
    if i upload the code in the espruino, it works.
    in a more complexe prog, it generate error in the code and nothing works (i've took some time to understand the prob)
    if i change the let for a var
    no error anymore and code run on the espruino

    let phrase= "";
    function test() {
      let tire = 7;  
      switch (tire) {
        case 7:
          // try a let
          let vTemp = Math.random(); 
          console.log(vTemp);
          break;
        default:
          break;
      }
    }
    
    function onInit() {
      setInterval(test,1000);
    }
    

    is it an error?

    regards

  • @Mrbbp As the same code runs in Chrome I believe this is an Espruino parser bug. Please submit an issue at https://github.com/espruino/Espruino/iss­ues.

  • @opichals done
    thanks.

  • Are you running with esprima (offline) minification on in the IDE?

    • If I just copy/paste this into the left-hand side of Espruino it works great.
    • If I run with no minification it works great
    • If I run with closure minification it works great

    This only seems to happen if you've turned on Esprima minification for your main source files?

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

chrome IDE error with a let in a switch case

Posted by Avatar for Mrbbp @Mrbbp

Actions