Node: TypeError: Cannot convert a Symbol value to a number at util.js:398:16

Created on 2 Mar 2017  Â·  4Comments  Â·  Source: nodejs/node

  • Version: v6.10.0
  • Platform: Linux richeve-biyaheroes 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: util
util.js:398
      return !(key >= 0 && key < raw.length);
               ^

TypeError: Cannot convert a Symbol value to a number
    at util.js:398:16
    at Array.filter (native)
    at formatValue (util.js:397:17)
    at formatProperty (util.js:794:15)
    at util.js:654:12
    at Array.map (native)
    at formatObject (util.js:653:15)
    at formatValue (util.js:592:16)
    at formatProperty (util.js:794:15)
    at util.js:654:12

I was experimenting and testing with my module on npm loosen at version 0.9.0

So my test case was this:

console.log( require( "util" ).inspect( loosen( global ), { "showHidden": true } ) );

When this code was run, the error above appears. Although it doesn't concern me really, but it bothers me because I was expecting util.inspect to handle things properly.

util

Most helpful comment

Quick reproduction without third-party libraries:

util.inspect(Object.assign(new String(), { [Symbol('A')]: 1 }), { showHidden:true })

All 4 comments

Quick reproduction without third-party libraries:

util.inspect(Object.assign(new String(), { [Symbol('A')]: 1 }), { showHidden:true })

if nobody is assigned yet i will do!

@CodeKittey This is already being addressed in https://github.com/nodejs/node/issues/11672, sorry… I’m removing the good first contribution label here

Fixed by d0b93c9fefce5ccaa41ef029d33ac9bab4f60f7d.

Was this page helpful?
0 / 5 - 0 ratings