Bug 202044 - Block scoped variables should be visible across scripts
Summary: Block scoped variables should be visible across scripts
Status: RESOLVED DUPLICATE of bug 193347
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 12
Hardware: Mac macOS 10.14
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-09-20 05:49 PDT by Paulius Varna
Modified: 2021-06-24 18:20 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paulius Varna 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>
Comment 1 Paulius Varna 2019-09-20 05:50:49 PDT
On Safari 12.1, 13 and 13.1 throws error at console.log({ two }). It shouldn't.
Comment 2 Radar WebKit Bug Importer 2019-09-20 09:58:08 PDT
<rdar://problem/55563029>
Comment 3 Yusuke Suzuki 2021-06-24 18:20:45 PDT
Fixed in bug 193347

*** This bug has been marked as a duplicate of bug 193347 ***