Njs: invoke accessors in Object.defineProperties()

Created on 22 Aug 2019  路  4Comments  路  Source: nginx/njs

>> var o = Object.defineProperties({}, { get x() { return { value: 1 }; } })
undefined
>> Object.getOwnPropertyDescriptor(o, 'x').value
TypeError: cannot get property "value" of undefined
    at main (native)
ES5.1 bug test262

All 4 comments

@drsm please try the following patch
https://gist.github.com/xeioex/36a7e33198679f46d2d0f733a9f2b92f

  - Ran 32254 tests
- - Passed 10338 tests (32.1%)
- - Failed 21916 tests (67.9%)
+ - Passed 10376 tests (32.2%)
+ - Failed 21878 tests (67.8%)

@xeioex

The patch looks fine, thanks!

Found a problem:

This place looks wrong.
An extensible flag should not be checked on update of property descriptor (spec)

var o = {};
Object.defineProperty(o, 'x', { configurable: true, get() { return 1; } });
Object.preventExtensions(o);
Object.defineProperty(o, 'x', { configurable: true, value: 2 });
o.x // 2

var o = {}
Object.defineProperty(o, 'x', { configurable: true, value: 1 });
Object.preventExtensions(o);
Object.defineProperty(o, 'x', { configurable: true, get() { return 2; } });
o.x // 2
=== built-ins/Object/defineProperty/8.12.9-9-b-i_1 failed in strict mode ===
=== built-ins/Object/defineProperty/8.12.9-9-b-i_2 failed in strict mode ===
=== built-ins/Object/defineProperty/8.12.9-9-c-i_1 failed in strict mode ===
=== built-ins/Object/defineProperty/8.12.9-9-c-i_2 failed in strict mode ===

Should I create another issue?

@drsm

An extensible flag should not be checked on update of property descriptor (spec)

Good catch. Thanks.

Should I create another issue?

No. I will fix it as a part of this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rainerhenrichsen picture rainerhenrichsen  路  5Comments

drsm picture drsm  路  5Comments

laith-leo picture laith-leo  路  5Comments

axipo picture axipo  路  3Comments

drsm picture drsm  路  5Comments