Skip to content

Unnecessary TypeError from util.inspect(Object.setPrototypeOf(function() {}, null)) #19511

Description

@iamstolis
  • Version: v8.9.4
  • Platform: Linux stola-ThinkPad 3.16.0-38-generic io.js on The Changelog! #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: util

util.inspect(Object.setPrototypeOf(function() {}, null)) results in

TypeError: Cannot read property 'name' of null
    at formatValue (util.js:523:35)
    at Object.inspect (util.js:324:10)

Note that this is the code that is used by REPL to print the result of Object.setPrototypeOf(function() {}, null) expression.

This TypeError is confusing and unnecessary. It comes from constructor.name in util.js:523. Few lines above (line 457) there is const ctorName = ... code that attempts to avoid problems like this, i.e., it would be sufficient to use ctorName instead of constructor.name on line 523.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions