pxt icon indicating copy to clipboard operation
pxt copied to clipboard

incorrect function value capture

Open mmoskal opened this issue 4 years ago • 0 comments

The following crashes on hardware (and probably sim as well):

function bugTest() {
   let q = 0
   function foo() { // const foo = () => { // fixes the issue
     q++
   }
   const tmp = () => {
     const bar = foo // here foo is referenced as if we were in bugTest; instead it should be captured
     if (typeof bar != "function")
       throw "oops"
   }
   tmp()
}
bugTest()

mmoskal avatar May 19 '21 20:05 mmoskal