Skip to content

Spec Mismatch in Array.of #1322

@stonechoe

Description

@stonechoe

Following code behaves differently depending on whether the native version is loaded, or if the polyfill is required and loaded:

let of = require("core-js-pure/es/array/of");

let handler = {
  has: () => {
    throw 42;
  },
};

let x = function () {
  return new Proxy({}, handler);
};

of.call(x, 0)

It throws with the polyfill, while it doesn't with the native implementation.
Although it is unusual to implement proxy to throw an exception, but even without throwing, it can still introduce silent bugs due to side effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions