duktape icon indicating copy to clipboard operation
duktape copied to clipboard

setting __proto__ in an object literal does not behave as expected

Open semmypurewal opened this issue 2 years ago • 1 comments

Thanks for Duktape! I've had a lot of fun playing around with it as a hobby over the last couple years. This is the first issue I've stumbled upon.

In Duktape 2.7, it doesn't seem like I can set the __proto__ property in an object literal. I haven't looked at the spec, but according to this article it should be allowed. Here's an example that I would expect to evaluate to true but it evaluates to false in Duktape:

Object.getPrototypeOf({ __proto__ : null }) == null;
// => false

This does evaluate to true in V8.

This may seems like an edge case, but I found it because I'm writing JSI bindings for Duktape 2.7. In one of their tests they use this pattern.

semmypurewal avatar Jul 06 '22 00:07 semmypurewal

You're right, __proto__ is at present not supported. Both obj.__proto__ and object literal __proto__ were specified as legacy features but in ES 13.0 __proto__ in object literal seems to be a mainline feature (obj.__proto__ is still legacy), so it needs to be added.

svaarala avatar Jul 10 '22 21:07 svaarala