Bug 219275 - block scope + const + hoisted function using the const = ReferenceError
Summary: block scope + const + hoisted function using the const = ReferenceError
Status: RESOLVED DUPLICATE of bug 163209
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: Safari 14
Hardware: All iOS 12
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-24 07:25 PST by Jakub G (dailymotion)
Modified: 2020-12-01 17:21 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub G (dailymotion) 2020-11-24 07:25:21 PST
Open the following test page:
> https://jg-testpage.netlify.app/safari/const-inside-if.html

Its contents for reference:
```
  <script>
    if (true) {
      const MY_CONST = 'MY_CONST';
      function myFunction() {
        console.log(MY_CONST);
      }
      myFunction();
    }
  </script>
```

Expected:
> see "MY_CONST" logged

Actual:
> ReferenceError

Other browsers' behavior:
> "MY_CONST" is logged in latest Chrome, Firefox, EdgeLegacy 18
Comment 1 Jakub G (dailymotion) 2020-11-24 07:26:18 PST
I repro the issue on all stable versions of Safari from 14.0 down to 10.1 (didn't test more)
Comment 2 Jakub G (dailymotion) 2020-11-27 09:35:44 PST
Just a small update: it seems to work fine in Safari in strict mode, but not in sloppy mode.

https://jg-testpage.netlify.app/safari/const-inside-if.html
https://jg-testpage.netlify.app/safari/const-inside-if-strict.html

Chrome 50+: OK both strict/sloppy mode
Firefox 50+: OK both strict/sloppy mode
Safari: OK strict mode, KO in sloppy mode
Comment 3 Radar WebKit Bug Importer 2020-12-01 07:26:14 PST
<rdar://problem/71849401>
Comment 4 Ross Kirsling 2020-12-01 17:21:12 PST
Thanks for the report -- Annex B.3.3 non-conformance has been deprioritized for a long time, but I think there is intention to correct this in the near future.

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