[Webkit-unassigned] [Bug 175254] New: ReferenceError when accessing closed over let/const inside an eval
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sun Aug 6 19:06:09 PDT 2017
https://bugs.webkit.org/show_bug.cgi?id=175254
Bug ID: 175254
Summary: ReferenceError when accessing closed over let/const
inside an eval
Product: WebKit
Version: Safari 10
Hardware: All
OS: All
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: diogomfranco at gmail.com
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.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170807/ee375ebd/attachment.html>
More information about the webkit-unassigned
mailing list