pythontutor-dev / pythontutor

11 stars 4 forks source link

global let-defined vars appear in wrong frame inside of lambda execution #49

Open pgbovine opened 4 years ago

pgbovine commented 4 years ago

http://pythontutor.com/visualize.html#code=let%20categoryList%20%3D%20%5B'tiger'%5D%0Aif%20%28true%29%20%7B%0A%20%20let%20categories%20%3D%20'our%20categories%20are%3A'%0A%20%20//%20BUG%3A%20inside%20the%20forEach%20lambda%20frames,%20categories%20should%20appear%20in%20the%20global%20frame%20and%20NOT%20the%20local%20frame%0A%20%20categoryList.forEach%28c%20%3D%3E%20%7B%0A%20%20%20%20console.log%28'in%20if',%20c%29%0A%20%20%20%20categories%20%2B%3D%20%60%24%7Bc%7D,%20%60%0A%20%20%7D%29%0A%7D&cumulative=false&curInstr=4&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=js&rawInputLstJSON=%5B%5D&textReferences=false

pgbovine commented 4 years ago

note: either leave "categories" in the global frame since that's the most accurate; or if we can't easily do that, then maybe it should be printed as "parent:categories" to be consistent with how other closure variables are printed?