chakra-core / chakra-core/ChakraCore

[RegExp] Can't make "lastIndex" property of a RegExp instance non-writable

Open
#238 7 comments 0 reactions 0 assignees View on GitHub
Bug Severity: 3
Dominant language
JavaScript
Stars
9.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

According to the spec, the `lastIndex` property of a RegExp instance has attributes `{[[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false}` and, as per [Section 6.1.7.1 Property Attributes](https://tc39.github.io/ecma262/#sec-property-attributes), it is possible to change `[[Writable]]` to `false` even when `[[Configurable]]` is `false`. However, on ChakraCore, it isn't possible.

Repro steps:

```
var re = /./;
var desc = Object.getOwnPropertyDescriptor(re, 'lastIndex');
WScript.Echo(desc.writable === true);

Object.defineProperty(re, 'lastIndex', {writable: false});
desc = Object.getOwnPropertyDescriptor(re, 'lastIndex');
WScript.Echo(desc.writable === false); // Currently prints "false"
```

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.