Skip to content

delete on an optional chain returns true without deleting the property #5319

Open

Description

@trackoor

Applying delete to a non-short-circuited optional chain (such as delete o?.a) evaluates the property access and returns true, but leaves the property on the object.

JerryScript revision

v3.0.0 and master (b7069350)

Build platform

macOS 26.3 (Darwin 25.3.0 arm64)

Build steps
tools/build.py --profile=es.next
Test case
var o = { a: 1 };
print(delete o?.a, "a" in o);

var p = { b: { c: 2 } };
print(delete p?.b.c, "c" in p.b);

var q = { a: 1 };
print(delete q?.["a"], "a" in q);
Output
true true
true true
true true
Expected behavior

It should print true false on all three lines, as V8 and SpiderMonkey do and as ECMA-262 requires (delete on a non-short-circuited OptionalExpression receives a property Reference and must invoke [[Delete]] on the base object).

Credit: https://ucsbplse.github.io/

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions