Bug 202044
Summary: | Block scoped variables should be visible across scripts | ||
---|---|---|---|
Product: | WebKit | Reporter: | Paulius Varna <paul.varna> |
Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | fpizlo, mark.lam, ross.kirsling, saam, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | Safari 12 | ||
Hardware: | Mac | ||
OS: | macOS 10.14 | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=147813 |
Paulius Varna
Const and let should be scoped to global context if used in top level script. (warning, global context is not the same as global object).
Explanation: https://www.youtube.com/watch?v=5LEuJNLfLN0
Reproduction:
<script>
var one = true;
const two = true;
</script>
<script type="module">
var three = true;
const four = true;
</script>
<script type="module">
console.log({ one });
console.log({ two });
console.log({ three }); // should throw
console.log({ four }); // should throw
</script>
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Paulius Varna
On Safari 12.1, 13 and 13.1 throws error at console.log({ two }). It shouldn't.
Radar WebKit Bug Importer
<rdar://problem/55563029>
Yusuke Suzuki
Fixed in bug 193347
*** This bug has been marked as a duplicate of bug 193347 ***