Skip to content

Incorrect inspection of Set iterator for set.entries() #24629

Description

@targos
  • Version: 10, 11, master
  • Platform: Linux
  • Subsystem: util
var set = new Set([1, 2])
console.log(set.entries())

In Node 6 and 8, it outputs:

SetIterator { [ 1, 1 ], [ 2, 2 ] }

In Node 10, 11 and master:

[Set Iterator] { 1, 2 }

Activity

  1. added
    utilIssues and PRs related to the built-in util module.
    on Nov 24, 2018
  2. added
    v8 engineIssues and PRs related to the V8 dependency.
    confirmed-bugIssues and PRs for confirmed bugs.
    and removed
    v8 engineIssues and PRs related to the V8 dependency.
    on Nov 24, 2018
  3. devsnek commented on Nov 24, 2018

    @devsnek
    Member

    Object::PreviewEntries reports unkeyed and gives the flat array.

    @nodejs/v8

  4. targos commented on Nov 24, 2018

    @targos
    MemberAuthor

    Yeah, Chrome has the same behavior:

    image

  5. Trott commented on Nov 24, 2018

    @Trott
    Member

    /ping @BridgeAR

  6. BridgeAR commented on Nov 24, 2018

    @BridgeAR
    Member

    AFAIC this works as intended. With the change to using Object::PreviewEntries this difference has been discussed as well and we decided to follow chrome.
    The set entries only contain the values, so there is no need to display it as an array with the value duplicated.

  7. devsnek commented on Nov 24, 2018

    @devsnek
    Member

    @BridgeAR its not an accurate representation of the actual iterator results though...

    > new Set([2, 4]).entries()
    [Set Iterator] { 2, 4 }
    > // oh ok its just some numbers
    > new Set([2, 4]).entries().next()
    { value: [ 2, 2 ], done: false }
    > // wait value is an array now?
    >
  8. targos commented on Nov 24, 2018

    @targos
    MemberAuthor

    It's true that they contain the values but they are still in arrays, so IMHO it is confusing to not see that in the preview.

  9. BridgeAR commented on Nov 25, 2018

    @BridgeAR
    Member

    I just fixed Object::PreviewEntries to work as intended locally and I'll raise a PR to V8 as soon as I set up the whole machinery for V8 PRs and I'll backport that as soon as it lands.

    ruben@BridgeAR-T450s:~/repos/node/node$ ./node
    > a = new Set([1,2,3])
    Set { 1, 2, 3 }
    > a.values()
    [Set Iterator] { 1, 2, 3 }
    > a.keys()
    [Set Iterator] { 1, 2, 3 }
    > a.entries()
    [Set Iterator] { [ 1, 1 ], [ 2, 2 ], [ 3, 3 ] }
    > process.versions
    { http_parser: '2.8.0',
      node: '12.0.0-pre',
      v8: '7.0.276.38-node.13',
    

    Refs: #20831 (the original PR that changed the behavior)

  10. targos commented on Dec 16, 2018

    @targos
    MemberAuthor

    @BridgeAR what's the status?

  11. BridgeAR commented on Dec 18, 2018

    @BridgeAR
    Member

    @targos I have to fix the Node.js test expectation first in another PR for V8 as those tests will now fail (Which is intended). I am working on that.

    The actual CL to fix the preview: https://chromium-review.googlesource.com/c/v8/v8/+/1350790

  12. added a commit that references this issue on Feb 4, 2019
  13. 3 remaining items

  14. added a commit that references this issue on Mar 12, 2019
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.v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions