[Webkit-unassigned] [Bug 275143] New: ReferenceError doesn't include variable name in error message

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 5 00:55:41 PDT 2024


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

            Bug ID: 275143
           Summary: ReferenceError doesn't include variable name in error
                    message
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: jarred at jarredsumner.com

`ReferenceError` in JSC does not include the variable name.


If we run the following in `jsc`:

```
❯ jsc -e 'const fetch = fetch("https://example.com")'
Exception: ReferenceError: Cannot access uninitialized variable.
global code@[Command Line]:1:20
```

If the run the following in `node`:
```
❯ node -e 'const fetch = fetch("https://example.com")'
// ...
ReferenceError: Cannot access 'fetch' before initialization
```

If we run the same code in Firefox:
```
Uncaught ReferenceError: can't access lexical declaration 'fetch' before initialization
```

Of these, JavaScriptCore is the only one which does not include the variable name in ReferenceError.

We've addressed this in bun's WebKit fork here: https://github.com/oven-sh/WebKit/pull/56/files. If it's helpful, feel free to use the code. There's probably a better way to do it where it passes the identifier via the property offset of the target and avoids heap-allocating a JSString but I'm not totally sure

-- 
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/20240605/ae624913/attachment.htm>


More information about the webkit-unassigned mailing list