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.
It is somewhat "fixed" in master. But it will print [undefined] in this case and that is confusing as well. It should actually say [Function]. I am going to fix it in master and backport it to 9.x and maybe we can still get a backport in 8.x as well.
While working on this I realized that we do not really support for any data type. It is probably not possible to always show the data for all objects (e.g., Set and Map) as before but it should at least not fail.
Yes, my primary concern here is the error being thrown. We have some objects with properties similar to Object.setPrototypeOf(function() {}, null) and it is annoying to see the errors while manipulating them in REPL. Personally, I don't care about particular formatting of such objects.
Fixed by 10c850b
Most helpful comment
It is somewhat "fixed" in master. But it will print
[undefined]in this case and that is confusing as well. It should actually say[Function]. I am going to fix it in master and backport it to 9.x and maybe we can still get a backport in 8.x as well.