<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>275143</bug_id>
          
          <creation_ts>2024-06-05 00:55:41 -0700</creation_ts>
          <short_desc>ReferenceError doesn&apos;t include variable name in error message</short_desc>
          <delta_ts>2025-09-17 16:02:46 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jarred Sumner">jarred</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>karlcow</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2039807</commentid>
    <comment_count>0</comment_count>
    <who name="Jarred Sumner">jarred</who>
    <bug_when>2024-06-05 00:55:41 -0700</bug_when>
    <thetext>`ReferenceError` in JSC does not include the variable name.


If we run the following in `jsc`:

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

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

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

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

We&apos;ve addressed this in bun&apos;s WebKit fork here: https://github.com/oven-sh/WebKit/pull/56/files. If it&apos;s helpful, feel free to use the code. There&apos;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&apos;m not totally sure</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2040940</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-06-12 00:56:14 -0700</bug_when>
    <thetext>&lt;rdar://problem/129659300&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2130671</commentid>
    <comment_count>2</comment_count>
    <who name="">ccarley2</who>
    <bug_when>2025-07-16 15:26:58 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/48153</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2143791</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-09-17 16:02:41 -0700</bug_when>
    <thetext>Committed 300119@main (412a6c047fa6): &lt;https://commits.webkit.org/300119@main&gt;

Reviewed commits have been landed. Closing PR #48153 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>