RESOLVED FIXED 175254
ReferenceError when accessing closed over let/const inside an eval
https://bugs.webkit.org/show_bug.cgi?id=175254
Summary ReferenceError when accessing closed over let/const inside an eval
Diogo Franco
Reported 2017-08-06 19:06:09 PDT
This problem has affected me for quite a while, but I have managed to get a small reproducible snippet going. ``` eval("const loggers = new Map(); const defaultLogger = getDefaultLogger(); function getDefaultLogger() { return loggers.get('default'); }") ``` This crashes with a `ReferenceError` on accessing loggers inside the getDefaultLogger closure. This error only happens inside an `eval`. Even changing the kind of `eval` to be `Function("the eval argument from above")()` instead avoids the error. Changing the `loggers` declaration into a `var` also works around the issue. This kind of code is probably impossible to find in the wild, but it affects developers working with webpack, as one of its debugging modes wraps each individual bundled module into an eval statement for faster source map updates. If the developer both enables the "eval" mode and skips converting ES2015 code to ES5 (because your local development browser, Safari in this case, ought to support it), you get mystery crashes on valid code.
Attachments
Yusuke Suzuki
Comment 1 2017-08-08 14:22:41 PDT
Thank you. It seems that this issue is fixed :) Safari TP does not pose this issue.
Note You need to log in before you can comment on or make changes to this bug.