RESOLVED FIXED275143
ReferenceError doesn't include variable name in error message
https://bugs.webkit.org/show_bug.cgi?id=275143
Summary ReferenceError doesn't include variable name in error message
Jarred Sumner
Reported 2024-06-05 00:55:41 PDT
`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
Attachments
Radar WebKit Bug Importer
Comment 1 2024-06-12 00:56:14 PDT
ccarley2
Comment 2 2025-07-16 15:26:58 PDT
EWS
Comment 3 2025-09-17 16:02:41 PDT
Committed 300119@main (412a6c047fa6): <https://commits.webkit.org/300119@main> Reviewed commits have been landed. Closing PR #48153 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.