Skip to content

Array converted to an array-like Object #437

@Gilad-Gur-Andelman

Description

@Gilad-Gur-Andelman

Hi, I have this issue.

To reproduce, please run this code: (you can run it for example here)

const { VM } = require('vm2')
const assert = require('assert').strict;

const vm = new VM()
const res = vm.run('[1, 2, 3]')
assert.deepEqual(res,[1,2,3])

It yields this error:

AssertionError: Expected values to be strictly deep-equal:
+ actual - expected

  [
    1,
    2,
    3,
+   '0': 1,
+   '1': 2,
+   '2': 3
  ]

I believe this problem is closely related to this issue, where collaborator @XmiliaH wrote
This is back for all versions as the fix broke Object.keys. As this is only a issue when logging objects this is acceptable.

However, as you can see, this is not only a logging issue.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions