You are reading a single comment by @yngv126399 and its replies. Click here to read the full conversation.
  • I've narrowed down a bug to when I use Esprima's Mangle to shorten variable names (other minification options don't generate the error).

    I'm seeing an error in the Bangle emulator when I execute this:

    // works fine
    g.clear();
    
    function dothis() {
      g.clear();
    }
    
    function test(one, two, three, four, five) {
      let arrTmp = 0; //new Uint8Array(12);
      for(let i=0; i<1; i++) {}
      
      // fails
      g.clear();
      dothis();
    }
    
    test();
    

    I'm getting this error:

    >Uncaught Error: Function "clear" not found!
     at line 1 col 23
    let a=0;for(let g=0;g<1;g++);g.clear(),dothis()
                                   ^
    in function "test" called from line 1 col 92
    ...(),dothis()}g.clear(),test()
                                  ^
    

    You can see that it changed the loop variable to 'g' , which should still be a local variable, but it clearly affects Bangle's 'g'.

    However, if you do any one of the following, the error goes away and the Bangle 'g' is fine:

    • if you comment out g.clear() and use the "dothis()" function instead
    • if you comment out the "let arrTmp" assignment
    • if you comment out the empty for loop
    • if you reduce the argument list to 4 items

    Just thought I'd share; not sure whether this is an Esprima bug, or an interpreter bug (a "let g=" within a for loop should be its own scope and not interfere with global context?)

About

Avatar for yngv126399 @yngv126399 started