[Webkit-unassigned] [Bug 227281] New: function within a block statement has broken scope for const/let

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 23 01:09:47 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=227281

            Bug ID: 227281
           Summary: function within a block statement has broken scope for
                    const/let
           Product: WebKit
           Version: Safari 14
          Hardware: Mac (Intel)
                OS: macOS 11
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: samuel.elg at sourcedefense.com

When a function within a block scope tries to access a variable declared with `const`/`let` on the wrapping scope a RefferenceError is thrown.

Reproducible example:
```
{
  const a = true; // also happens with "let" declarations.
  function main() {
    console.log(a);
  }
  main();
}
```

Accessing `a` on the 4th line throws an error: "ReferenceError: Can't find variable: a".
The expected behavior would be for the "a" variable to be in the scope of the function "main".

-- 
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/20210623/d4e34bba/attachment.htm>


More information about the webkit-unassigned mailing list