Bug 147656 - Poor Error Message / Call Stack for TypeError: Cannot call a class constructor
Summary: Poor Error Message / Call Stack for TypeError: Cannot call a class constructor
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-04 15:27 PDT by Joseph Pecoraro
Modified: 2015-08-04 15:28 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-08-04 15:27:21 PDT
* SUMMARY
Poor Error Message / Call Stack for TypeError: Cannot call a class constructor. It points to the "constructor" instead of the "call" site.

* TEST:

  1  <script>
  2  class MyClass {
  3      constructor() { this.name = "name"; }
  4  }
  5  function OtherClass() {
  6      MyClass.call(this);
  7  }
  8  x = new OtherClass;
  9  </script>


* STEPS TO REPRODUCE
1. Run attached test case
  => Error in console points to the "constructor" line, expected it to point to the frame above, the "call" site.
  TypeError: Cannot call a class constructor
    MyClass test.html:3
    OtherClass test.html:6
    (anonymous function) test.html:8

* NOTES
- Inspector currently has an off by 1 error in its stack trace output which is getting corrected at the moment.
Comment 1 Joseph Pecoraro 2015-08-04 15:28:20 PDT
Also it might be good to use the class' name if it has one. It might not though.