Skip to content

util: faulty inspect output #15288

Closed
Closed

Description

@BridgeAR
  • Version: all
  • Platform: all
  • Subsystem: util
const a = []
a["00"] = true
Object.keys(a)
// [ '00' ]
util.inspect(a)
// Node.js < 8.4 will log
// '[  ]'
// Node.js 8.4 and master will log
// '[ true ]'
// It should be
// '[ \'00\': true ]'

Activity

  1. added
    utilIssues and PRs related to the built-in util module.
    on Sep 9, 2017
  2. BridgeAR commented on Sep 9, 2017

    @BridgeAR
    MemberAuthor

    This will be fixed by #14881

  3. addaleax commented on Sep 9, 2017

    @addaleax
    Member

    Btw, not sure whether your patch will fix this as well, but on master:

    > a = []
    []
    > a[10000000000000] = true // not a valid array index
    true
    > a
    [  ]
    > a[0] = true
    true
    > a
    [ true ]
    > a[10] = true
    true
    > a
    [ true, <9 empty items>, true, <9999999999989 empty items>, true ]
  4. BridgeAR commented on Sep 9, 2017

    @BridgeAR
    MemberAuthor

    This is the output with my patch. It is better but still not correct. I add a patch for that as well.

    > a = []
    []
    > a[10000000000000] = true // not a valid array index
    true
    > a
    [ '10000000000000': true ]
    > a[0] = true
    true
    > a
    [ true, '10000000000000': true ]
    > a[10] = true
    true
    > a
    [ true, <9 empty items>, true, <9999999999989 empty items>, true ]
  5. added 2 commits that reference this issue on Sep 14, 2017
    c5fc61f
    ee5415e
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

    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