chakra-core / chakra-core/ChakraCore

RegExp.prototype.lastIndex cannot be set properly via Object.defineProperty

Open
#6,512 1 comment 0 reactions 0 assignees View on GitHub
Bug ES Spec Conformance
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

## Description

When using the function `RegExp()` to create a RegExp object. The object's `lastIndex` property should be 0 and the property descriptor `writable` should be true. But when i use the function `Object.defineProperty` to redefine the property `lastIndex` . Chakra failed to change its value while all other engines such as V8, SpiderMonkey, and JavascriptCore changed successfully. Is this a normal behavior of Chakra?

## Version

chakra 1.11.22

## Run Command

`chakra-1_11_22/bin/ch testcase.js`

## Testcase

~~~javascript
var regexp5 = new RegExp(/abc/);
print(regexp5.lastIndex);

Object.defineProperty(regexp5, "lastIndex", {
value: "\w?\B",
writable: false
});
print(regexp5.lastIndex);
~~~

## Output

~~~javascript
0
0
~~~

## Expected output

~~~javascript
0
w?B
~~~

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.