Skip to content

Proxy deleteProperty throws TypeError when returning false #9118

Closed
@i8-pi

Description

@i8-pi
Contributor
  • Version: v6.8.1
  • Platform: Linux 4.7.6-1-ARCH x86_64 GNU/Linux
  • Subsystem:

When returning false from handler.deleteProperty of a Proxy, a TypeError is thrown

'use strict';
const p = new Proxy({}, { deleteProperty: () => false });
delete p.a;
TypeError: 'deleteProperty' on proxy: trap returned falsish for property 'a'

From my understanding of the Spec, the delete operation should return false (on step 9) instead of throwing an Error.

Activity

bnoordhuis

bnoordhuis commented on Oct 16, 2016

@bnoordhuis
Member

Can you report this to V8? From reading the spec I would agree with you that it's a bug but I wonder if the spec itself isn't deficient here. Here is an example of what I mean:

'use strict';
var o = /* either {} or a proxy */;
if (undefined === Object.getOwnPropertyDescriptor(o, 'a'))
  if (false === delete p.a)
    throw Error('uncanny');

With a deleteProperty returning false, you would reach the exception, something that couldn't happen with a regular object (assuming no .a property on the prototype chain) because delete o.undefinedProperty === true.

i8-pi

i8-pi commented on Oct 17, 2016

@i8-pi
ContributorAuthor

Not a bug, apparently.
https://bugs.chromium.org/p/v8/issues/detail?id=5523

From the spec quoted in the v8 bug, the delete operator is required to throw if it returns false in strict mode .

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

    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

        Participants

        @bnoordhuis@i8-pi

        Issue actions

          Proxy deleteProperty throws TypeError when returning false · Issue #9118 · nodejs/node