Bug 202044

Summary: Block scoped variables should be visible across scripts
Product: WebKit Reporter: Paulius Varna <paul.varna>
Component: JavaScriptCoreAssignee: 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
Reported 2019-09-20 05:49:01 PDT
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
Paulius Varna
Comment 1 2019-09-20 05:50:49 PDT
On Safari 12.1, 13 and 13.1 throws error at console.log({ two }). It shouldn't.
Radar WebKit Bug Importer
Comment 2 2019-09-20 09:58:08 PDT
Yusuke Suzuki
Comment 3 2021-06-24 18:20:45 PDT
Fixed in bug 193347 *** This bug has been marked as a duplicate of bug 193347 ***
Note You need to log in before you can comment on or make changes to this bug.