chakra-core / chakra-core/ChakraCore
RegExp.prototype.lastIndex cannot be set properly via Object.defineProperty
- 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
Assessment
This issue has not been assessed yet.