Bug 275143
| Summary: | ReferenceError doesn't include variable name in error message | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jarred Sumner <jarred> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | karlcow, mark.lam, webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Jarred Sumner
`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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/129659300>
ccarley2
Pull request: https://github.com/WebKit/WebKit/pull/48153
EWS
Committed 300119@main (412a6c047fa6): <https://commits.webkit.org/300119@main>
Reviewed commits have been landed. Closing PR #48153 and removing active labels.