Title: util.inherits does not establish prototype chain · Issue #4179 · nodejs/node · GitHub
Open Graph Title: util.inherits does not establish prototype chain · Issue #4179 · nodejs/node
X Title: util.inherits does not establish prototype chain · Issue #4179 · nodejs/node
Description: In inherits.js Object.setPrototypeOf is being called with the wrong parameters. The reason for me assuming that the wrong parameters are being used is (REPL) > function MyError() {} > util.inherits(MyError, Error); > MyError { [Function:...
Open Graph Description: In inherits.js Object.setPrototypeOf is being called with the wrong parameters. The reason for me assuming that the wrong parameters are being used is (REPL) > function MyError() {} > util.inherits...
X Description: In inherits.js Object.setPrototypeOf is being called with the wrong parameters. The reason for me assuming that the wrong parameters are being used is (REPL) > function MyError() {} > util.in...
Opengraph URL: https://github.com/nodejs/node/issues/4179
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"util.inherits does not establish prototype chain","articleBody":"In inherits.js Object.setPrototypeOf is being called with the wrong parameters.\n\nThe reason for me assuming that the wrong parameters are being used is\n\n(REPL)\n\n```\n\u003e function MyError() {}\n\u003e util.inherits(MyError, Error);\n\u003e MyError\n{ [Function: MyError]\n super_: \n { [Function: Error]\n captureStackTrace: [Function: captureStackTrace],\n stackTraceLimit: 10 } }\n\u003e Error.isPrototypeOf(MyError);\nfalse\n```\n\nWhile inheritance sort of works, the prototype chain is actually never established.\n\n```\n\u003e myerr = new MyError()\n[Error]\n\u003e myerr instanceof MyError\ntrue\n\u003e myerr instanceof Error\ntrue\n```\n\nReplacing the existing call to Object.setPrototypeOf() by\n\n```\nObject.setPrototypeOf(ctor, superCtor);\n```\n\nSee https://github.com/nodejs/node/blob/master/lib/util.js#L805.\n\n(REPL)\n\n```\n\u003e function MyError() {}\n\u003e util.inherits(MyError, Error);\n\u003e MyError\n[Function: OError]\n\u003e Error.isPrototypeOf(MyError);\ntrue\n```\n\nYet, instanceof will now fail\n\n```\n\u003e myerr = new MyError()\n[Error]\n\u003e myerr instanceof MyError\ntrue\n\u003e myerr instanceof Error\nfalse\n```\n\nWhen using the new class feature, everything works as expected, though\n\n(REPL)\n\n```\n\u003e class MyError extends Error {}\n[Function: MyError]\n\u003e Error.isPrototypeOf(MyError)\ntrue\n\u003e myerr = new MyError()\n[Error]\n\u003e myerr instanceof MyError\ntrue\n\u003e myerr instanceof Error\ntrue\n```\n","author":{"url":"https://github.com/silkentrance","@type":"Person","name":"silkentrance"},"datePublished":"2015-12-07T22:13:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/4179/node/issues/4179"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:48e3ec73-2b8d-7a88-645a-4301d7a283a6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B07C:77702:2A783C:3DB9A0:6A4E0104 |
| html-safe-nonce | 168d0d69ee66db964518afd606d34283073ac1e3d808e189e45da656f5678688 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDdDOjc3NzAyOjJBNzgzQzozREI5QTA6NkE0RTAxMDQiLCJ2aXNpdG9yX2lkIjoiMTE2MjM2MjAyNDg5NTU3ODM3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 24cde7a0ff287b1069693bae2ce2ac2eaf62fba7332819bb757df673c21ac4d9 |
| hovercard-subject-tag | issue:120880347 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/4179/issue_layout |
| twitter:image | https://opengraph.githubassets.com/caefc7f72fedb193c75dab262d97014abdf49d2a4861faca11338c3b0d3b067b/nodejs/node/issues/4179 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/caefc7f72fedb193c75dab262d97014abdf49d2a4861faca11338c3b0d3b067b/nodejs/node/issues/4179 |
| og:image:alt | In inherits.js Object.setPrototypeOf is being called with the wrong parameters. The reason for me assuming that the wrong parameters are being used is (REPL) > function MyError() {} > util.inherits... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | silkentrance |
| hostname | github.com |
| expected-hostname | github.com |
| None | df0492960db29b4938cb72070351d6b1d0c6c0767b27ceb8394bbf4fcc0223c6 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 52bde38e24398476f8eb1e0760c81346c6a00812 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width